Commit b37fab87 by jscat

nyx weapp: 功能更新

1. 调整获取字符串(ch/en)长度的程序到app.js
2. 确保图片轮循的时候价格不会更改
3. 确保活动页面的价格保留两位小数
4. content显示时候显示记录换行
5. quantity默认100
6. 图片载入完毕之前, '下一步'button不可点击
parent 36e5bc5f
//app.js //app.js
...@@ -580,6 +580,18 @@ App({ ...@@ -580,6 +580,18 @@ App({
}) })
}, },
// 统计字符数
// 英文占1个字符,中文汉字占2个字符
gblen: function(str) { // eslint-disable-line
let len = 0;
for (let i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
len += 2;
} else {
len++;
}
}
return len;
},
}) })
// pages/activity/activity-info/activity-info.js // pages/activity/activity-info/activity-info.js
...@@ -22,6 +22,7 @@ Page({ ...@@ -22,6 +22,7 @@ Page({
scrollLeft: 0, //切换栏的滚动条位置 scrollLeft: 0, //切换栏的滚动条位置
// 基础数据 // 基础数据
curImage: 0, // 用于image switch, //图片轮循的时候, 不同步更新价格 jscat 20200921
curIndex: 0, // 给选中的tab加粗 curIndex: 0, // 给选中的tab加粗
activityInfo: {}, // 活动基础信息 activityInfo: {}, // 活动基础信息
products: [], // 活动类别详情 products: [], // 活动类别详情
...@@ -83,7 +84,7 @@ Page({ ...@@ -83,7 +84,7 @@ Page({
activityInfo['num_like'] = options.num_like; activityInfo['num_like'] = options.num_like;
activityInfo['address_name'] = options.address_name; activityInfo['address_name'] = options.address_name;
activityInfo['product_desc'] = options.product_desc; activityInfo['product_desc'] = options.product_desc;
activityInfo['unit_price'] = options.unit_price; activityInfo['unit_price'] = parseFloat(options.unit_price).toFixed(2);
activityInfo['member_id'] = options.member_id; activityInfo['member_id'] = options.member_id;
activityInfo['member_name'] = options.member_name; activityInfo['member_name'] = options.member_name;
activityInfo['member_slogan'] = options.member_slogan; activityInfo['member_slogan'] = options.member_slogan;
...@@ -270,7 +271,7 @@ Page({ ...@@ -270,7 +271,7 @@ Page({
var result = {} var result = {}
result["productId"] = res.data.data[i].productId result["productId"] = res.data.data[i].productId
result["productDesc"] = res.data.data[i].productDesc result["productDesc"] = res.data.data[i].productDesc
result["unitPrice"] = res.data.data[i].unitPrice result["unitPrice"] = res.data.data[i].unitPrice.toFixed(2)
result["quantity"] = res.data.data[i].quantity result["quantity"] = res.data.data[i].quantity
result["defaultStatus"] = res.data.data[i].defaultStatus result["defaultStatus"] = res.data.data[i].defaultStatus
products.push(result) products.push(result)
...@@ -295,20 +296,20 @@ Page({ ...@@ -295,20 +296,20 @@ Page({
//滑动获取选中商品 //滑动获取选中商品
getSelectItem: function (e) { getSelectItem: function (e) {
var that = this; var that = this;
var preCurIndex = that.data.curIndex; var preCurImage = that.data.curImage;
var itemWidth = e.detail.scrollWidth / that.data.activityInfo.note_image.length;//每个商品的宽度 var itemWidth = e.detail.scrollWidth / that.data.activityInfo.note_image.length;//每个商品的宽度
var scrollLeft = e.detail.scrollLeft;//滚动宽度 var scrollLeft = e.detail.scrollLeft;//滚动宽度
var curIndex = Math.round(scrollLeft / itemWidth);//通过Math.round方法对滚动大于一半的位置进行进位 var curImage = Math.round(scrollLeft / itemWidth);//通过Math.round方法对滚动大于一半的位置进行进位
var newScrollLeft = 0 var newScrollLeft = 0
// 目标: 始终让图片居中显示 // 目标: 始终让图片居中显示
if (curIndex != preCurIndex if (curImage != preCurImage
|| (curIndex == that.data.activityInfo.note_image.length - 1 && scrollLeft > that.data.windowWidth * (that.data.activityInfo.note_image.length - 1)) || (curImage == that.data.activityInfo.note_image.length - 1 && scrollLeft > that.data.windowWidth * (that.data.activityInfo.note_image.length - 1))
) )
{ {
newScrollLeft = that.data.windowWidth * curIndex newScrollLeft = that.data.windowWidth * curImage
that.setData({ that.setData({
scrollLeft : newScrollLeft, scrollLeft : newScrollLeft,
curIndex : curIndex, curImage : curImage, //图片轮循的时候, 不同步更新价格 jscat 20200921
}); });
} }
}, },
......
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs> <wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<span>地点: {{activityInfo.address_name}}</span> <span>地点: {{activityInfo.address_name}}</span>
</view> </view>
<view class="note-content"> <view class="note-content">
内容: {{activityInfo.content}} <text>内容: {{activityInfo.content}}</text>
</view> </view>
</view> </view>
......
// pages/activity/activity.js // pages/activity/activity.js
...@@ -371,7 +371,7 @@ Page({ ...@@ -371,7 +371,7 @@ Page({
result["point"] = res.data.data[i].point result["point"] = res.data.data[i].point
result["address_name"] = res.data.data[i].addressName result["address_name"] = res.data.data[i].addressName
result["product_desc"] = res.data.data[i].productDesc result["product_desc"] = res.data.data[i].productDesc
result["unit_price"] = res.data.data[i].unitPrice result["unit_price"] = res.data.data[i].unitPrice.toFixed(2)
result["note_image"] = res.data.data[i].noteImage.split("::") result["note_image"] = res.data.data[i].noteImage.split("::")
var start_datetime = res.data.data[i].startDatetime var start_datetime = res.data.data[i].startDatetime
var end_datetime = res.data.data[i].endDatetime var end_datetime = res.data.data[i].endDatetime
......
// pages/my/my-orders/my-orders.js // pages/my/my-orders/my-orders.js
...@@ -401,7 +401,7 @@ Page({ ...@@ -401,7 +401,7 @@ Page({
//重置数据 //重置数据
//设置支付按钮可点击 //设置支付按钮可点击
var canClick = true; var canClick = true;
_this .setData({ canClick }) _this.setData({ canClick })
//回到首页 //回到首页
_this.toHome(); _this.toHome();
......
// pages/member/activity-post/activity-edit/activity-edit.js // pages/member/activity-post/activity-edit/activity-edit.js
...@@ -70,7 +70,7 @@ Page({ ...@@ -70,7 +70,7 @@ Page({
//如果未设置products, 初始值为"" //如果未设置products, 初始值为""
if(products.length == 0) if(products.length == 0)
{ {
products = [{ productDesc: "", unitPrice: 0, quantity: 0, }] products = [{ productDesc: "", unitPrice: 0, quantity: 100, }]
} }
//设置本地变量 //设置本地变量
...@@ -151,7 +151,7 @@ Page({ ...@@ -151,7 +151,7 @@ Page({
addList: function(){ addList: function(){
var _this = this; var _this = this;
var list = _this.data.products; var list = _this.data.products;
var newData = { productDesc: "", unitPrice: 0, quantity: 0, }; var newData = { productDesc: "", unitPrice: 0, quantity: 100, };
list.push(newData);//实质是添加lists数组内容,使for循环多一次 list.push(newData);//实质是添加lists数组内容,使for循环多一次
this.setData({ this.setData({
products: list, products: list,
......
// pages/member/activity-post/activity-post.js // pages/member/activity-post/activity-post.js
...@@ -44,6 +44,9 @@ Page({ ...@@ -44,6 +44,9 @@ Page({
//下一次被选中的记号 //下一次被选中的记号
nextSign: 0, nextSign: 0,
// 下一步按钮可用状态
canClick: true,
}, },
onLoad: function () { onLoad: function () {
...@@ -101,8 +104,14 @@ Page({ ...@@ -101,8 +104,14 @@ Page({
onNavigateToEdit() { onNavigateToEdit() {
var _this = this; var _this = this;
var photoArray = _this.data.photoArray var photoArray = _this.data.photoArray
var nextSign = 1 var nextSign = 1
_this.setData({ nextSign }) _this.setData({ nextSign })
//先设置支付按钮不可点击
var canClick = false;
_this.setData({ canClick })
if(photoArray.length == 0) // 添加照片 if(photoArray.length == 0) // 添加照片
{ {
_this.addPhoto() _this.addPhoto()
...@@ -150,8 +159,13 @@ Page({ ...@@ -150,8 +159,13 @@ Page({
*/ */
promise_addPhoto: function (resolve, reject) { promise_addPhoto: function (resolve, reject) {
var _this = this; var _this = this;
//先设置支付按钮不可点击
var canClick = false;
_this.setData({ _this.setData({
photoArray: [] photoArray: [],
canClick: canClick
}) })
console.log("===this is addPhoto"); console.log("===this is addPhoto");
wx.chooseImage({ wx.chooseImage({
...@@ -174,9 +188,15 @@ Page({ ...@@ -174,9 +188,15 @@ Page({
//添加图片 //添加图片
addPhoto: function () { addPhoto: function () {
var _this = this; var _this = this;
//先设置支付按钮不可点击
var canClick = false;
_this.setData({ _this.setData({
photoArray: [] photoArray: [],
canClick: canClick
}) })
console.log("===this is addPhoto"); console.log("===this is addPhoto");
wx.chooseImage({ wx.chooseImage({
sizeType: ['original, compressed'], // 可以指定是原图还是压缩图,默认二者都有 sizeType: ['original, compressed'], // 可以指定是原图还是压缩图,默认二者都有
...@@ -274,12 +294,19 @@ Page({ ...@@ -274,12 +294,19 @@ Page({
} }
else //图片处理完毕 else //图片处理完毕
{ {
var nextSign = _this.data.nextSign var nextSign = _this.data.nextSign
var photoArray = _this.data.photoArray var photoArray = _this.data.photoArray
//设置支付按钮可点击
var canClick = true;
_this.setData({ canClick })
if(nextSign == 1) if(nextSign == 1)
{ {
_this.navigateToEdit() _this.navigateToEdit()
} }
} }
}, },
......
<!-- /pages/member/activity-post/activity-post.wxml --> <!-- /pages/member/activity-post/activity-post.wxml -->
<!-- /pages/member/activity-post/activity-post.wxml --> <!-- /pages/member/activity-post/activity-post.wxml -->
<view class="page" style="height:100%;width:100%"> <view class="page" style="height:100%;width:100%">
<block> <block>
<button class="weui-btn" type="warn" bindtap="onNavigateToEdit">下一步</button> <button class="weui-btn" type="warn" disabled="{{!canClick}}" bindtap="onNavigateToEdit">下一步</button>
</block> </block>
<form> <form>
......
// pages/member/activity-post/activity-submit/activity-submit.js // pages/member/activity-post/activity-submit/activity-submit.js
...@@ -17,6 +17,7 @@ Page({ ...@@ -17,6 +17,7 @@ Page({
memberInfo: {}, // member_name/address 临时temp数据 memberInfo: {}, // member_name/address 临时temp数据
content: "", content: "",
contentLength: 0,
//当textarea获取焦点时自适应高度,失去焦点时不自适应高度 //当textarea获取焦点时自适应高度,失去焦点时不自适应高度
//自适应高度时,style中的height无效 //自适应高度时,style中的height无效
...@@ -104,11 +105,13 @@ Page({ ...@@ -104,11 +105,13 @@ Page({
} }
var content = "" var content = ""
var contentLength = 0
if(app.globalData.postData.startDatetime != "") if(app.globalData.postData.startDatetime != "")
{ {
content = app.globalData.postData.photoContent; //获取content content = app.globalData.postData.photoContent; //获取content
contentLength = app.gblen(content)
} }
_this.setData({ content }) _this.setData({ content, contentLength })
var defaultCity = app.globalData.defaultCity var defaultCity = app.globalData.defaultCity
_this.setData({ defaultCity }) _this.setData({ defaultCity })
...@@ -550,7 +553,8 @@ Page({ ...@@ -550,7 +553,8 @@ Page({
// //
app.globalData.postData.photoContent = e.detail.value app.globalData.postData.photoContent = e.detail.value
var content = e.detail.value var content = e.detail.value
_this.setData({ content }) var contentLength = app.gblen(content)
_this.setData({ content, contentLength })
}, },
// 添加口号 // 添加口号
bindSlogan(e) { bindSlogan(e) {
......
<view class="page-body"> <view class="page-body">
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<view class="weui-cell"> <view class="weui-cell">
<view class="weui-cell__bd"> <view class="weui-cell__bd">
<textarea auto-height="{{auto_height}}" bindblur='areablur' bindfocus='areafocus' class="weui-textarea" bindinput='bindKeyInput' name="inputContent" placeholder="请输入活动内容" style="height: 3.3em" value="{{content}}"/> <textarea auto-height="{{auto_height}}" bindblur='areablur' bindfocus='areafocus' class="weui-textarea" bindinput='bindKeyInput' name="inputContent" placeholder="请输入活动内容" style="height: 3.3em" value="{{content}}"/>
<view class="weui-textarea-counter">{{content.length}}/300</view> <view class="weui-textarea-counter">{{contentLength}}/2000</view>
</view> </view>
</view> </view>
</view> </view>
......
// pages/my/my-orders/my-orders.js // pages/my/my-orders/my-orders.js
...@@ -271,7 +271,7 @@ Page({ ...@@ -271,7 +271,7 @@ Page({
for(var i=0; i<orderInfo[key]['order_item'].length;i++ ) for(var i=0; i<orderInfo[key]['order_item'].length;i++ )
{ {
content = orderInfo[key].title + "·" + orderInfo[key]['order_item'][i].product_desc content = orderInfo[key].title + "·" + orderInfo[key]['order_item'][i].product_desc
row_height += gblen(content) > 29 ? 76.8 * 2 : 60 * 2 row_height += app.gblen(content) > 29 ? 76.8 * 2 : 60 * 2
} }
// item_height : 130 + 20 + 120*2 + 30*3, // item_height : 130 + 20 + 120*2 + 30*3,
...@@ -342,16 +342,3 @@ Page({ ...@@ -342,16 +342,3 @@ Page({
}) })
// 英文占1个字符,中文汉字占2个字符
function gblen(str) { // eslint-disable-line
let len = 0;
for (let i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
len += 2;
} else {
len++;
}
}
return len;
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论