Commit 7b927411874b809ede38f2463bdcc89fe183390a

Authored by 后端研发-苏泰源
2 parents a0fd8492 cd9501ab

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

components/diy_goodsGroup/diy_goodsGroup.js
@@ -326,7 +326,7 @@ Component({ @@ -326,7 +326,7 @@ Component({
326 //--- 判断是等级会员,且在有效期范围内 --- 326 //--- 判断是等级会员,且在有效期范围内 ---
327 if (user.card_field && now < end) { 327 if (user.card_field && now < end) {
328 var card_name = ob.name_map.get(user.card_field); 328 var card_name = ob.name_map.get(user.card_field);
329 - if (card_name.length > 4) card_name = card_name.substring(0, 4); 329 + if (card_name && card_name.length > 4) card_name = card_name.substring(0, 4);
330 th.setData({ 330 th.setData({
331 card_field: user.card_field, 331 card_field: user.card_field,
332 card_name: card_name, 332 card_name: card_name,
components/long_warn/long_warn.wxml
1 <view class="rim" wx:if="{{is_show}}"> 1 <view class="rim" wx:if="{{is_show}}">
2 <view class="content flex-center"> 2 <view class="content flex-center">
3 <view class="con_view" style="width:{{width>0?width+'rpx':'auto'}}"> 3 <view class="con_view" style="width:{{width>0?width+'rpx':'auto'}}">
4 - <view class="con_view_img">  
5 - <image wx:if="{{type}}" src="{{iurl}}/miniapp/images/sucess_g.png"></image><!-- 成功 -->  
6 - <image wx:else src="{{iurl}}/miniapp/images/gt.png"></image> <!-- 失败 --> 4 + <view class="con_view_img flex ai_c jc-center">
  5 + <view wx:if="{{type}}" class="circle-box flex ai_c jc-center">
  6 + <text class="iconfont icon-dagou"></text>
  7 + </view><!-- 成功 -->
  8 + <text wx:else class="iconfont icon-info" style="font-size: 78rpx"></text> <!-- 失败 -->
7 </view> 9 </view>
8 <view class="msg">{{val}}</view> 10 <view class="msg">{{val}}</view>
9 </view> 11 </view>
components/long_warn/long_warn.wxss
  1 +@import '../../app.wxss';
1 .cover-layer { 2 .cover-layer {
2 position: fixed; 3 position: fixed;
3 left: 0; 4 left: 0;
@@ -21,8 +22,15 @@ @@ -21,8 +22,15 @@
21 .con_view{ 22 .con_view{
22 min-width:180rpx; max-width: 720rpx; width: auto; padding: 40rpx 30rpx; background-color: #000; border-radius:22rpx; text-align: center; 23 min-width:180rpx; max-width: 720rpx; width: auto; padding: 40rpx 30rpx; background-color: #000; border-radius:22rpx; text-align: center;
23 } 24 }
24 -.con_view .con_view_img{ height: 120rpx;} 25 +.con_view .con_view_img{ height: 120rpx; color: #fff}
25 .con_view image{ width: 84rpx; height: 84rpx;} 26 .con_view image{ width: 84rpx; height: 84rpx;}
26 .msg{ 27 .msg{
27 color:#fff; font-size: 32rpx 28 color:#fff; font-size: 32rpx
28 } 29 }
  30 +
  31 +.circle-box{
  32 + width: 80rpx;
  33 + height: 80rpx;
  34 + border: 1rpx solid #fff;
  35 + border-radius: 50%;
  36 +}
components/serviceCard_list/serviceCard_list.js
@@ -70,7 +70,7 @@ Component({ @@ -70,7 +70,7 @@ Component({
70 //--- 判断是等级会员,且在有效期范围内 --- 70 //--- 判断是等级会员,且在有效期范围内 ---
71 if (user.card_field && now < end) { 71 if (user.card_field && now < end) {
72 var card_name = ob.name_map.get(user.card_field); 72 var card_name = ob.name_map.get(user.card_field);
73 - if (card_name.length > 4) card_name = card_name.substring(0, 8); 73 + if (card_name && card_name.length > 4) card_name = card_name.substring(0, 8);
74 th.setData({ 74 th.setData({
75 card_field: user.card_field, 75 card_field: user.card_field,
76 card_name: card_name, 76 card_name: card_name,
packageC/pages/presell/cart/cart.js
@@ -2057,6 +2057,9 @@ Page({ @@ -2057,6 +2057,9 @@ Page({
2057 } 2057 }
2058 dd.order_amount = parseFloat(th.data.order_m).toFixed(2); 2058 dd.order_amount = parseFloat(th.data.order_m).toFixed(2);
2059 2059
  2060 + if(getApp().globalData.scene)
  2061 + dd.scene=getApp().globalData.scene;
  2062 +
2060 console.log(JSON.stringify(dd)); 2063 console.log(JSON.stringify(dd));
2061 wx.request({ 2064 wx.request({
2062 url: oo.url + '/api/weshop/order/pay/payPresellWk', 2065 url: oo.url + '/api/weshop/order/pay/payPresellWk',
packageC/pages/presell/goodsInfo/goodsInfo.js
@@ -3957,7 +3957,7 @@ Page({ @@ -3957,7 +3957,7 @@ Page({
3957 if (end_time < ut.gettimestamp()) { 3957 if (end_time < ut.gettimestamp()) {
3958 wx.showToast({title:err_txt, icon: 'none', duration: 3000}); 3958 wx.showToast({title:err_txt, icon: 'none', duration: 3000});
3959 setTimeout(function () { 3959 setTimeout(function () {
3960 - ut.wx_back(); 3960 + getApp().goto("/pages/index/index/index");
3961 }, 2000) 3961 }, 2000)
3962 gnext=0; 3962 gnext=0;
3963 return false; 3963 return false;
packageD/pages/AI-test-skin/analyse/analyse.js
@@ -217,7 +217,8 @@ Page({ @@ -217,7 +217,8 @@ Page({
217 "image": getApp().globalData.face_SourceImg, 217 "image": getApp().globalData.face_SourceImg,
218 "face_field": "age,expression,face_shape,gender,glasses,landmark,landmark150,quality,eye_status,emotion,face_type,mask,spoofing", 218 "face_field": "age,expression,face_shape,gender,glasses,landmark,landmark150,quality,eye_status,emotion,face_type,mask,spoofing",
219 "image_type": "URL", 219 "image_type": "URL",
220 - "store_id":setting.stoid 220 + "store_id":setting.stoid,
  221 + "user_id":getApp().globalData.user_id
221 } 222 }
222 //开始调用百度接口,进行对图片进行判断是否符合标准 223 //开始调用百度接口,进行对图片进行判断是否符合标准
223 this.json_post("/api/weshop/baidubce/face/skindetect", data, function (res) { 224 this.json_post("/api/weshop/baidubce/face/skindetect", data, function (res) {
@@ -369,8 +370,21 @@ Page({ @@ -369,8 +370,21 @@ Page({
369 } 370 }
370 th.analyse_by_bd(data); 371 th.analyse_by_bd(data);
371 } else { 372 } else {
372 - var msg = th.data.err_map[res.data.code + ""];  
373 - th.go_error1(msg); 373 + var msg = th.data.err_map[res.data.code + ""];
  374 + if(msg){
  375 + th.go_error1(msg);
  376 + }else{
  377 + wx.showToast({
  378 + title:res.data.msg,
  379 + icon: 'none',
  380 + duration: 3000
  381 + })
  382 +
  383 + setTimeout(function () {
  384 + ut.wx_back()
  385 + },2000)
  386 +
  387 + }
374 } 388 }
375 }) 389 })
376 }, 390 },
packageD/pages/AI-test-skin/index/aiskin.js
1 /* 1 /*
2 * @Author: abson 2 * @Author: abson
3 * @Date: 2022-02-11 14:13:05 3 * @Date: 2022-02-11 14:13:05
4 - * @LastEditTime: 2022-03-26 17:03:01 4 + * @LastEditTime: 2022-04-12 12:05:50
5 * @LastEditors: Please set LastEditors 5 * @LastEditors: Please set LastEditors
6 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 6 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
7 * @FilePath: \MShopWeApp\packageB\pages\AI-test-skin\index\aiskin.js 7 * @FilePath: \MShopWeApp\packageB\pages\AI-test-skin\index\aiskin.js
@@ -25,12 +25,14 @@ Page({ @@ -25,12 +25,14 @@ Page({
25 * 生命周期函数--监听页面加载 25 * 生命周期函数--监听页面加载
26 */ 26 */
27 onLoad: function (options) { 27 onLoad: function (options) {
28 - getApp().globalData.user_id = options?.user_id;  
29 - getApp().getUserFir();  
30 - var user = getApp().globalData.userInfo;  
31 - if (!user || !getApp().globalData.user_id) {  
32 - let url = "/pages/togoin/togoin";  
33 - app.goto(url); 28 + let user_id = options.user_id || getApp().globalData.user_id;
  29 + if (user_id) {
  30 + getApp().getUserFir();
  31 + } else {
  32 + setTimeout(function () {
  33 + let url = "/pages/togoin/togoin";
  34 + app.goto(url);
  35 + }, 1000)
34 } 36 }
35 }, 37 },
36 38
@@ -58,6 +60,13 @@ Page({ @@ -58,6 +60,13 @@ Page({
58 60
59 goto(e) { 61 goto(e) {
60 62
  63 + var need=e.currentTarget.dataset.need;
  64 + if(!need){
  65 + let url = e.currentTarget.dataset.url;
  66 + app.goto(url);
  67 + return false;
  68 + }
  69 +
61 this.check_num(function () { 70 this.check_num(function () {
62 var user = getApp().globalData.userInfo; 71 var user = getApp().globalData.userInfo;
63 if (!user) { 72 if (!user) {
@@ -109,27 +118,7 @@ Page({ @@ -109,27 +118,7 @@ Page({
109 118
110 }, 119 },
111 120
112 - check_num: function (func) {  
113 - //判断右没有开AI测肤  
114 - getApp().promiseGet("/api/weshop/wx/weappSkin/get/" + setting.stoid, {}).then(rs => {  
115 - if (rs.data.code != 0 || !rs.data.data) {  
116 - wx.showToast({  
117 - title: "未开通测肤功能,请联系商家",  
118 - icon: 'none',  
119 - duration: 3000  
120 - })  
121 - } else if (!rs.data.data.skin_num || rs.data.data.skin_num <= 0) {  
122 - wx.showToast({  
123 - title: "测肤功能的使用次数已经达到上限,请联系商家",  
124 - icon: 'none',  
125 - duration: 3000  
126 - })  
127 - } else {  
128 - func();  
129 - }  
130 - })  
131 - },  
132 - 121 +
133 async getHistoryData() { 122 async getHistoryData() {
134 if (!getApp().globalData.user_id) return false; 123 if (!getApp().globalData.user_id) return false;
135 if (this.data.show_his) return false; 124 if (this.data.show_his) return false;
@@ -149,7 +138,65 @@ Page({ @@ -149,7 +138,65 @@ Page({
149 if (res.code == 0 && res.data.pageData.length > 0) { 138 if (res.code == 0 && res.data.pageData.length > 0) {
150 this.setData({ show_his: 1 }) 139 this.setData({ show_his: 1 })
151 } 140 }
152 - } 141 + },
  142 +
  143 + check_num:function (func) {
  144 + //判断右没有开AI测肤
  145 + getApp().promiseGet("/api/weshop/wx/weappSkin/get/"+setting.stoid,{}).then(rs=>{
  146 + if(rs.data.code!=0 || !rs.data.data){
  147 + wx.showToast({
  148 + title: "未开通测肤功能,请联系商家",
  149 + icon: 'none',
  150 + duration: 3000
  151 + })
  152 + }else if(!rs.data.data.skin_num || rs.data.data.skin_num<=0){
  153 + wx.showToast({
  154 + title: "测肤功能的使用次数已经达到上限,请联系商家",
  155 + icon: 'none',
  156 + duration: 3000
  157 + })
  158 + }else{
  159 + var rdata={
  160 + store_id:setting.stoid,
  161 + user_id:getApp().globalData.user_id
  162 + }
  163 + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{
  164 + if(res.data.code==0){
  165 + func();
  166 + }else{
  167 + wx.showToast({
  168 + title: res.data.msg,
  169 + icon: 'none',
  170 + duration: 3000
  171 + })
  172 + }
  173 + })
  174 + }
  175 + })
  176 + },
  177 +
  178 + /**
  179 + * @param {Object} url //url地址
  180 + * @param {Object} data //data入参
  181 + * @param {Object} succ //成功的回调
  182 + * @param {Object} fail //失败的回调
  183 + */
  184 + json_post: function (url, data, succ, fail, mathod) {
  185 + var Mathod = "POST";
  186 + if (mathod) Mathod = mathod;
  187 + if (url.indexOf("http") == -1) url = getApp().globalData.setting.url + url;
  188 + var str = JSON.stringify(data);
  189 + wx.request({
  190 + url: url,
  191 + data: str,
  192 + method: Mathod,
  193 + header: {
  194 + 'content-type': 'application/json'
  195 + },// 设置请求的 header
  196 + success: function (res) { succ(res); },
  197 + fail: function (res) { fail(res); }
  198 + })
  199 + },
153 200
154 201
155 }) 202 })
156 \ No newline at end of file 203 \ No newline at end of file
packageD/pages/AI-test-skin/index/aiskin.wxml
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 </view> 5 </view>
6 <view style="position: relative;width: 100%"> 6 <view style="position: relative;width: 100%">
7 <image style="width: 100%" src="{{iurl}}/miniapp/images/skinimg/shouye.jpeg" mode="widthFix"></image> 7 <image style="width: 100%" src="{{iurl}}/miniapp/images/skinimg/shouye.jpeg" mode="widthFix"></image>
8 - <view class="start_btn" bindtap="goto" data-url="/packageD/pages/AI-test-skin/shoot_notice/shoot_notice"> 8 + <view class="start_btn" bindtap="goto" data-need="1" data-url="/packageD/pages/AI-test-skin/shoot_notice/shoot_notice">
9 <text>开始测肤</text> 9 <text>开始测肤</text>
10 </view> 10 </view>
11 </view> 11 </view>
packageD/pages/AI-test-skin/select_photo/select_photo.js
@@ -197,8 +197,46 @@ Page({ @@ -197,8 +197,46 @@ Page({
197 duration: 3000 197 duration: 3000
198 }) 198 })
199 }else{ 199 }else{
200 - func(); 200 + var rdata={
  201 + store_id:setting.stoid,
  202 + user_id:getApp().globalData.user_id
  203 + }
  204 + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{
  205 + if(res.data.code==0){
  206 + func();
  207 + }else{
  208 + wx.showToast({
  209 + title: res.data.msg,
  210 + icon: 'none',
  211 + duration: 3000
  212 + })
  213 + }
  214 + })
201 } 215 }
202 }) 216 })
203 - } 217 + },
  218 +
  219 +
  220 + /**
  221 + * @param {Object} url //url地址
  222 + * @param {Object} data //data入参
  223 + * @param {Object} succ //成功的回调
  224 + * @param {Object} fail //失败的回调
  225 + */
  226 + json_post: function (url, data, succ, fail, mathod) {
  227 + var Mathod = "POST";
  228 + if (mathod) Mathod = mathod;
  229 + if (url.indexOf("http") == -1) url = getApp().globalData.setting.url + url;
  230 + var str = JSON.stringify(data);
  231 + wx.request({
  232 + url: url,
  233 + data: str,
  234 + method: Mathod,
  235 + header: {
  236 + 'content-type': 'application/json'
  237 + },// 设置请求的 header
  238 + success: function (res) { succ(res); },
  239 + fail: function (res) { fail(res); }
  240 + })
  241 + },
204 }) 242 })
205 \ No newline at end of file 243 \ No newline at end of file
packageD/pages/AI-test-skin/shoot_notice/shoot_notice.js
@@ -99,32 +99,37 @@ Page({ @@ -99,32 +99,37 @@ Page({
99 99
100 //选择图片 100 //选择图片
101 takePhoto() { 101 takePhoto() {
  102 +
102 var that = this; 103 var that = this;
103 - getApp().globalData.no_clear=1;  
104 - that.setData({selecting:1});  
105 - wx.chooseImage({  
106 - count: 1,  
107 - sizeType: ['compressed'],  
108 - sourceType: ['album', 'camera'],  
109 - success(res) {  
110 - var tempFilePaths = res.tempFilePaths  
111 - console.log(tempFilePaths);  
112 - console.log(res.tempFiles[0].size / 1024 + 'kb');  
113 - var size1 =res.tempFiles[0].size;  
114 - var size = res.tempFiles[0].size / 1024; //kb单位  
115 - // tempFilePath可以作为img标签的src属性显示图片  
116 - var img = tempFilePaths[0];  
117 - that.setData({  
118 - imagesrc: img,  
119 - })  
120 - that.imgToMin(img, size,size1); //获取图片后压缩 104 + this.check_num(function () {
  105 + getApp().globalData.no_clear=1;
  106 + that.setData({selecting:1});
  107 + wx.chooseImage({
  108 + count: 1,
  109 + sizeType: ['compressed'],
  110 + sourceType: ['album', 'camera'],
  111 + success(res) {
  112 + var tempFilePaths = res.tempFilePaths
  113 + console.log(tempFilePaths);
  114 + console.log(res.tempFiles[0].size / 1024 + 'kb');
  115 + var size1 =res.tempFiles[0].size;
  116 + var size = res.tempFiles[0].size / 1024; //kb单位
  117 + // tempFilePath可以作为img标签的src属性显示图片
  118 + var img = tempFilePaths[0];
  119 + that.setData({
  120 + imagesrc: img,
  121 + })
  122 + that.imgToMin(img, size,size1); //获取图片后压缩
121 123
122 - },  
123 - fail(err) {  
124 - that.setData({selecting:0})  
125 - console.log(err);  
126 - } 124 + },
  125 + fail(err) {
  126 + that.setData({selecting:0})
  127 + console.log(err);
  128 + }
  129 + })
127 }) 130 })
  131 +
  132 +
128 }, 133 },
129 //图片转码64 134 //图片转码64
130 base64(url, type) { 135 base64(url, type) {
@@ -231,4 +236,62 @@ Page({ @@ -231,4 +236,62 @@ Page({
231 }, 236 },
232 }) 237 })
233 }, 238 },
  239 +
  240 + check_num:function (func) {
  241 + //判断右没有开AI测肤
  242 + getApp().promiseGet("/api/weshop/wx/weappSkin/get/"+setting.stoid,{}).then(rs=>{
  243 + if(rs.data.code!=0 || !rs.data.data){
  244 + wx.showToast({
  245 + title: "未开通测肤功能,请联系商家",
  246 + icon: 'none',
  247 + duration: 3000
  248 + })
  249 + }else if(!rs.data.data.skin_num || rs.data.data.skin_num<=0){
  250 + wx.showToast({
  251 + title: "测肤功能的使用次数已经达到上限,请联系商家",
  252 + icon: 'none',
  253 + duration: 3000
  254 + })
  255 + }else{
  256 + var rdata={
  257 + store_id:setting.stoid,
  258 + user_id:getApp().globalData.user_id
  259 + }
  260 + this.json_post("/api/weshop/baidubce/face/skinvip",rdata,res=>{
  261 + if(res.data.code==0){
  262 + func();
  263 + }else{
  264 + wx.showToast({
  265 + title: res.data.msg,
  266 + icon: 'none',
  267 + duration: 3000
  268 + })
  269 + }
  270 + })
  271 + }
  272 + })
  273 + },
  274 +
  275 + /**
  276 + * @param {Object} url //url地址
  277 + * @param {Object} data //data入参
  278 + * @param {Object} succ //成功的回调
  279 + * @param {Object} fail //失败的回调
  280 + */
  281 + json_post: function (url, data, succ, fail, mathod) {
  282 + var Mathod = "POST";
  283 + if (mathod) Mathod = mathod;
  284 + if (url.indexOf("http") == -1) url = getApp().globalData.setting.url + url;
  285 + var str = JSON.stringify(data);
  286 + wx.request({
  287 + url: url,
  288 + data: str,
  289 + method: Mathod,
  290 + header: {
  291 + 'content-type': 'application/json'
  292 + },// 设置请求的 header
  293 + success: function (res) { succ(res); },
  294 + fail: function (res) { fail(res); }
  295 + })
  296 + },
234 }) 297 })
235 \ No newline at end of file 298 \ No newline at end of file
pages/cart/cart/cart.js
@@ -2409,6 +2409,16 @@ Page({ @@ -2409,6 +2409,16 @@ Page({
2409 2409
2410 //--------------去结算------------ 2410 //--------------去结算------------
2411 async checkout() { 2411 async checkout() {
  2412 +
  2413 + if(getApp().is_sp_hao()){
  2414 + wx.showToast({
  2415 + title: "视频号不支持购物车购买",
  2416 + icon: 'none',
  2417 + duration: 2000
  2418 + });
  2419 + return false;
  2420 + }
  2421 +
2412 if (!this.data.total_num || this.data.total_num <= 0) return false; 2422 if (!this.data.total_num || this.data.total_num <= 0) return false;
2413 if (!this.data.is_load) return false; 2423 if (!this.data.is_load) return false;
2414 if (this.data.up_dating) { 2424 if (this.data.up_dating) {
@@ -2942,7 +2952,6 @@ Page({ @@ -2942,7 +2952,6 @@ Page({
2942 th.data.promgoods_list[p_item[0]]=promgoods_list; 2952 th.data.promgoods_list[p_item[0]]=promgoods_list;
2943 } 2953 }
2944 2954
2945 - var is_duo_gift=0;  
2946 for (var i in promgoods_list) { 2955 for (var i in promgoods_list) {
2947 var item = promgoods_list[i]; 2956 var item = promgoods_list[i];
2948 if (item.prom_type == 0) { 2957 if (item.prom_type == 0) {
@@ -2955,21 +2964,6 @@ Page({ @@ -2955,21 +2964,6 @@ Page({
2955 } 2964 }
2956 make_up_arr.push(elem); 2965 make_up_arr.push(elem);
2957 break; 2966 break;
2958 - }else{  
2959 - var json=JSON.parse(item.preferential_type);  
2960 - json.prom_id=prom.id;  
2961 - json.prom_name=prom.name;  
2962 - if(json.is_gift){  
2963 -  
2964 - var idx=send_gift_arr.findIndex(function (e) {  
2965 - return e.prom_id==prom.id;  
2966 - })  
2967 - if(idx!=-1){  
2968 - send_gift_arr[idx]=json;  
2969 - }else {  
2970 - send_gift_arr.push(json);  
2971 - }  
2972 - }  
2973 } 2967 }
2974 } else { 2968 } else {
2975 if (ob.num < item.condition) { 2969 if (ob.num < item.condition) {
@@ -2981,35 +2975,13 @@ Page({ @@ -2981,35 +2975,13 @@ Page({
2981 } 2975 }
2982 make_up_arr.push(elem); 2976 make_up_arr.push(elem);
2983 break; 2977 break;
2984 - }else{  
2985 - var json=JSON.parse(item.preferential_type);  
2986 - json.prom_id=prom.id;  
2987 - json.prom_name=prom.name;  
2988 - if(json.is_gift){  
2989 - var idx=send_gift_arr.findIndex(function (e) {  
2990 - return e.prom_id==prom.id;  
2991 - })  
2992 - if(idx!=-1){  
2993 - send_gift_arr[idx]=json;  
2994 - }else {  
2995 - send_gift_arr.push(json);  
2996 - }  
2997 - }  
2998 } 2978 }
2999 } 2979 }
3000 } 2980 }
3001 2981
3002 - //找到要送的活动  
3003 - var idx=send_gift_arr.findIndex(function (e) {  
3004 - return e.prom_id==prom.id;  
3005 - })  
3006 - if(idx!=-1){  
3007 - var cur_json=send_gift_arr[idx];  
3008 - if(parseInt(cur_json.zp_mode)==1) is_duo_gift=1;  
3009 - }  
3010 2982
3011 - //-- 只有在单赠品的时候,才要进行计算 --  
3012 - if(!is_duo_gift && idx>-1) { 2983 +
  2984 + //-- 只有在单赠品的时候,才要进行计算 --
3013 await getApp().request.promiseGet("/api/weshop/goods/getDiscount", { 2985 await getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
3014 data: { 2986 data: {
3015 price: ob.price, 2987 price: ob.price,
@@ -3022,80 +2994,107 @@ Page({ @@ -3022,80 +2994,107 @@ Page({
3022 if (res.data.code == 0) discount = res.data.data; 2994 if (res.data.code == 0) discount = res.data.data;
3023 }) 2995 })
3024 2996
3025 - if(!discount.zp_num || parseInt(discount.zp_num)==0) discount.zp_num=1;  
3026 - //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量---  
3027 - if (discount && discount['goods_id'] && discount.limit_num >= discount.bs*discount.zp_num  
3028 - && discount.gift_storecount >= discount.bs*discount.zp_num) {  
3029 - //如果这礼品超了情况下  
3030 - if (no_gift_arr.indexOf(discount.gift_id) != -1) continue;  
3031 - var o = discount.goodsinfo;  
3032 - //-- 默认等于1,兼容旧的活动 --  
3033 -  
3034 - var newd = {  
3035 - goods_id: o.goods_id,  
3036 - goods_num: discount.bs*discount.zp_num, //是赠品的翻倍  
3037 - pick_id: list.pid,  
3038 - user_id: app.globalData.user_id,  
3039 - store_id: os.stoid,  
3040 - goods_price: 0,  
3041 - guide_id: ob.guide_id ? ob.guide_id : 0,  
3042 - guide_type: ob.guide_type ? ob.guide_type : 0,  
3043 - member_goods_price: 0,  
3044 - goods_name: o.goods_name,  
3045 - goods_sn: o.goods_sn,  
3046 - sku: o.sku,  
3047 - is_gift: 1,  
3048 - prom_id: p_item[0],  
3049 - prom_type: 3,  
3050 - selected: 1,  
3051 - gift_id: discount.gift_id,  
3052 - original_img: th.data.imgUrl + o.original_img  
3053 - };  
3054 -  
3055 - list2.goods.push(newd);  
3056 - var all_num = 0;  
3057 - var all_limit_num = 0;  
3058 -  
3059 - for (var i in alllist) {  
3060 - var list_item = alllist[i];  
3061 - for (var j in list_item.goods) {  
3062 - //如果赠品的ID一样,要进行统计数量  
3063 - if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == newd.gift_id) {  
3064 - all_num += list_item.goods[j].goods_num;  
3065 - }  
3066 - if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == newd.gift_id && list_item.goods[j].prom_id == p_item[0]) {  
3067 - all_limit_num += list_item.goods[j].goods_num;  
3068 - }  
3069 -  
3070 - }  
3071 - }  
3072 -  
3073 - //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 --  
3074 - if (discount.gift_storecount < all_num || discount.limit_num < all_limit_num) {  
3075 - no_gift_arr.push(discount.gift_id);  
3076 - //--进入下一个循环 --  
3077 - continue;  
3078 - }  
3079 -  
3080 -  
3081 - var url = "/api/weshop/cart/delGift?store_id=" + newd.store_id + "&user_id=" +  
3082 - newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id  
3083 - await getApp().request.promiseDelete(url, {})  
3084 -  
3085 - var add_data = null;  
3086 - await getApp().request.promisePost("/api/weshop/cart/save", {  
3087 - data: newd  
3088 - }).then(res => {  
3089 - if (res.data.code == 0) {  
3090 - add_data = res.data.data;  
3091 - }  
3092 - })  
3093 - if (add_data) {  
3094 - newd.id = add_data.id;  
3095 - list.goods.push(newd);  
3096 - }  
3097 - }  
3098 - } 2997 + if(discount) {
  2998 +
  2999 + if (!discount.zp_num || parseInt(discount.zp_num) == 0) discount.zp_num = 1;
  3000 + //判断一下赠品的模式
  3001 + if (parseInt(discount.zp_mode)== 1 )
  3002 + {
  3003 +
  3004 + var a_stock_num=0;
  3005 + var a_limit_num=0;
  3006 + for(let iy in discount.giftsinfo){
  3007 + let item=discount.giftsinfo[iy];
  3008 + a_stock_num+= parseInt(item.gift_storecount);
  3009 + a_limit_num+=parseInt(item.limit_num);
  3010 + }
  3011 +
  3012 + var t_zp_num=parseInt(discount.zp_num)*parseInt(discount.bs);
  3013 + if(a_limit_num>=t_zp_num && a_stock_num>=t_zp_num ) {
  3014 +
  3015 + var json={};
  3016 + json.prom_id=prom.id;
  3017 + json.prom_name=prom.name;
  3018 + send_gift_arr.push(json);
  3019 + }
  3020 +
  3021 + }
  3022 + else
  3023 + {
  3024 + //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量---
  3025 + if (discount && discount['goods_id'] && discount.limit_num >= discount.bs * discount.zp_num
  3026 + && discount.gift_storecount >= discount.bs * discount.zp_num) {
  3027 + //如果这礼品超了情况下
  3028 + if (no_gift_arr.indexOf(discount.gift_id) != -1) continue;
  3029 + var o = discount.goodsinfo;
  3030 + //-- 默认等于1,兼容旧的活动 --
  3031 +
  3032 + var newd = {
  3033 + goods_id: o.goods_id,
  3034 + goods_num: discount.bs * discount.zp_num, //是赠品的翻倍
  3035 + pick_id: list.pid,
  3036 + user_id: app.globalData.user_id,
  3037 + store_id: os.stoid,
  3038 + goods_price: 0,
  3039 + guide_id: ob.guide_id ? ob.guide_id : 0,
  3040 + guide_type: ob.guide_type ? ob.guide_type : 0,
  3041 + member_goods_price: 0,
  3042 + goods_name: o.goods_name,
  3043 + goods_sn: o.goods_sn,
  3044 + sku: o.sku,
  3045 + is_gift: 1,
  3046 + prom_id: p_item[0],
  3047 + prom_type: 3,
  3048 + selected: 1,
  3049 + gift_id: discount.gift_id,
  3050 + original_img: th.data.imgUrl + o.original_img
  3051 + };
  3052 +
  3053 + list2.goods.push(newd);
  3054 + var all_num = 0;
  3055 + var all_limit_num = 0;
  3056 +
  3057 + for (var i in alllist) {
  3058 + var list_item = alllist[i];
  3059 + for (var j in list_item.goods) {
  3060 + //如果赠品的ID一样,要进行统计数量
  3061 + if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == newd.gift_id) {
  3062 + all_num += list_item.goods[j].goods_num;
  3063 + }
  3064 + if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == newd.gift_id && list_item.goods[j].prom_id == p_item[0]) {
  3065 + all_limit_num += list_item.goods[j].limit_num;
  3066 + }
  3067 +
  3068 + }
  3069 + }
  3070 +
  3071 + //-- 赠品的数量超出库存数量和会员的限制,这里是保证所有的赠品部会超出 --
  3072 + if (discount.gift_storecount < all_num || discount.limit_num < all_limit_num) {
  3073 + no_gift_arr.push(discount.gift_id);
  3074 + //--进入下一个循环 --
  3075 + continue;
  3076 + }
  3077 +
  3078 +
  3079 + var url = "/api/weshop/cart/delGift?store_id=" + newd.store_id + "&user_id=" +
  3080 + newd.user_id + "&goods_id=" + newd.goods_id + "&is_gift=1&pick_id=" + newd.pick_id + "&prom_id=" + newd.prom_id
  3081 + await getApp().request.promiseDelete(url, {})
  3082 +
  3083 + var add_data = null;
  3084 + await getApp().request.promisePost("/api/weshop/cart/save", {
  3085 + data: newd
  3086 + }).then(res => {
  3087 + if (res.data.code == 0) {
  3088 + add_data = res.data.data;
  3089 + }
  3090 + })
  3091 + if (add_data) {
  3092 + newd.id = add_data.id;
  3093 + list.goods.push(newd);
  3094 + }
  3095 + }
  3096 + }
  3097 + }
3099 3098
3100 } 3099 }
3101 //--更新购物车的前台渲染-- 3100 //--更新购物车的前台渲染--
@@ -3116,9 +3115,6 @@ Page({ @@ -3116,9 +3115,6 @@ Page({
3116 }); 3115 });
3117 } 3116 }
3118 3117
3119 - send_gift_arr=send_gift_arr.filter(function (e) {  
3120 - return e.zp_mode==="1";  
3121 - })  
3122 var gift_text = "requestData[" + cindex + "].send_gift_arr"; 3118 var gift_text = "requestData[" + cindex + "].send_gift_arr";
3123 //-- 如果有凑单的话 -- 3119 //-- 如果有凑单的话 --
3124 if (send_gift_arr.length > 0) { 3120 if (send_gift_arr.length > 0) {
pages/cart/cart/cart.wxml
@@ -162,7 +162,7 @@ @@ -162,7 +162,7 @@
162 162
163 <!-- 赠品的提示 --> 163 <!-- 赠品的提示 -->
164 <block wx:if="{{item.send_gift_arr}}"> 164 <block wx:if="{{item.send_gift_arr}}">
165 - <view bindtap="show_gift_toast" wx:for="{{item.send_gift_arr}}" wx:if="{{item.zp_mode}}" 165 + <view bindtap="show_gift_toast" wx:for="{{item.send_gift_arr}}"
166 class="fs28 pdr20 pdl20 pdb20 c-red2 flex jc_sb" style="padding: 10rpx 30rpx"> 166 class="fs28 pdr20 pdl20 pdb20 c-red2 flex jc_sb" style="padding: 10rpx 30rpx">
167 <text style="color: #333333">送赠品</text> 167 <text style="color: #333333">送赠品</text>
168 <text bindtap="tishi_gift">{{item.prom_name}}></text> 168 <text bindtap="tishi_gift">{{item.prom_name}}></text>
pages/cart/cart2/cart2.js
@@ -1210,7 +1210,13 @@ Page({ @@ -1210,7 +1210,13 @@ Page({
1210 item_map.s_intValue = get_data.intValue; 1210 item_map.s_intValue = get_data.intValue;
1211 item_map.s_coupon_id = get_data.coupon_id; 1211 item_map.s_coupon_id = get_data.coupon_id;
1212 item_map.s_coupon_num = get_data.coupon_num; 1212 item_map.s_coupon_num = get_data.coupon_num;
1213 - if (get_data.gift_id && get_data.goodsinfo) { 1213 +
  1214 +
  1215 + if (get_data.gift_id && parseInt(get_data.zp_mode)!=1
  1216 + && get_data.zp_num* item_map.bs<=get_data.limit_num
  1217 + && get_data.zp_num* item_map.bs<=get_data.gift_storecount
  1218 + ){
  1219 +
1214 item_map.gift_id = get_data.gift_id; 1220 item_map.gift_id = get_data.gift_id;
1215 item_map.gift_goods_id = get_data.goods_id; 1221 item_map.gift_goods_id = get_data.goods_id;
1216 item_map.gift_goods_name = get_data.goods_name; 1222 item_map.gift_goods_name = get_data.goods_name;
@@ -1233,9 +1239,26 @@ Page({ @@ -1233,9 +1239,26 @@ Page({
1233 1239
1234 if(parseInt(get_data.zp_mode)==1){ 1240 if(parseInt(get_data.zp_mode)==1){
1235 if(!send_gf[pickid]) send_gf[pickid]=[]; 1241 if(!send_gf[pickid]) send_gf[pickid]=[];
1236 - send_gf[pickid].push({  
1237 - pickup_id:pickid,giftsinfo:get_data.giftsinfo,zp_num:get_data.zp_num,  
1238 - gf_pr_name:item_map.name,prom_id:item_map.prom_id}); 1242 +
  1243 + var a_stock_num=0;
  1244 + var a_limit_num=0;
  1245 + for(let iy in get_data.giftsinfo){
  1246 + let item=get_data.giftsinfo[iy];
  1247 + a_stock_num+= parseInt(item.gift_storecount);
  1248 + a_limit_num+=parseInt(item.limit_num);
  1249 + }
  1250 +
  1251 + var t_zp_num=parseInt(get_data.zp_num)*parseInt(get_data.bs);
  1252 + if(a_limit_num>=t_zp_num && a_stock_num>=t_zp_num) {
  1253 +
  1254 + send_gf[pickid].push({
  1255 + pickup_id: pickid,
  1256 + giftsinfo: get_data.giftsinfo,
  1257 + zp_num: get_data.zp_num * get_data.bs,
  1258 + gf_pr_name: item_map.name,
  1259 + prom_id: item_map.prom_id
  1260 + });
  1261 + }
1239 } 1262 }
1240 } 1263 }
1241 }) 1264 })
@@ -4048,10 +4071,13 @@ Page({ @@ -4048,10 +4071,13 @@ Page({
4048 arr.s_coupon_id = get_data.coupon_id; 4071 arr.s_coupon_id = get_data.coupon_id;
4049 arr.s_coupon_num = get_data.coupon_num; 4072 arr.s_coupon_num = get_data.coupon_num;
4050 arr.zp_mode = get_data.zp_mode; 4073 arr.zp_mode = get_data.zp_mode;
4051 - arr.zp_num = get_data.zp_num; 4074 + arr.zp_num = get_data.zp_num?get_data.zp_num:1; //确保默认一个
4052 4075
4053 //-- 看是不是有赠品 -- 4076 //-- 看是不是有赠品 --
4054 - if (get_data.gift_id && parseInt(get_data.zp_mode)!=1){ 4077 + if (get_data.gift_id && parseInt(get_data.zp_mode)!=1
  4078 + && get_data.zp_num* arr.bs<=get_data.limit_num
  4079 + && get_data.zp_num* arr.bs<=get_data.gift_storecount
  4080 + ){
4055 arr.gift_id = get_data.gift_id; 4081 arr.gift_id = get_data.gift_id;
4056 arr.gift_goods_id = get_data.goods_id; 4082 arr.gift_goods_id = get_data.goods_id;
4057 arr.gift_goods_name = get_data.goods_name; 4083 arr.gift_goods_name = get_data.goods_name;
@@ -4077,9 +4103,23 @@ Page({ @@ -4077,9 +4103,23 @@ Page({
4077 var pickid=gg.pick_id; 4103 var pickid=gg.pick_id;
4078 if(parseInt(get_data.zp_mode)==1){ 4104 if(parseInt(get_data.zp_mode)==1){
4079 if(!send_gf[pickid]) send_gf[pickid]=[]; 4105 if(!send_gf[pickid]) send_gf[pickid]=[];
4080 - send_gf[pickid].push({  
4081 - pickup_id:pickid,giftsinfo:get_data.giftsinfo,zp_num:get_data.zp_num, 4106 +
  4107 + var a_stock_num=0;
  4108 + var a_limit_num=0;
  4109 + for(let iy in get_data.giftsinfo){
  4110 + let item=get_data.giftsinfo[iy];
  4111 + a_stock_num+= parseInt(item.gift_storecount);
  4112 + a_limit_num+=parseInt(item.limit_num);
  4113 + }
  4114 +
  4115 + var t_zp_num=parseInt(get_data.zp_num)*parseInt(get_data.bs);
  4116 + if(a_limit_num>= t_zp_num && a_stock_num>=t_zp_num ){
  4117 + send_gf[pickid].push({
  4118 + pickup_id:pickid,giftsinfo:get_data.giftsinfo,zp_num:get_data.zp_num*get_data.bs,
4082 gf_pr_name:prom.name,prom_id:prom.prom_id}); 4119 gf_pr_name:prom.name,prom_id:prom.prom_id});
  4120 +
  4121 + }
  4122 +
4083 th.setData({send_gf:send_gf}); 4123 th.setData({send_gf:send_gf});
4084 } 4124 }
4085 } 4125 }
@@ -4471,6 +4511,25 @@ Page({ @@ -4471,6 +4511,25 @@ Page({
4471 } 4511 }
4472 }, 4512 },
4473 4513
  4514 +
  4515 + //输入框输入数量的时候
  4516 + valueToNum:function (e){
  4517 + var th=this;
  4518 + var idx=e.currentTarget.dataset.item;
  4519 + var gift_item=this.data.giftsinfo[idx];
  4520 + var num=parseInt(e.detail.value);
  4521 + var txt="giftsinfo["+idx+"].goods_num";
  4522 + var is_true=th.check_out_num_cart(gift_item,this.data.gift_pkid,num);
  4523 + if(!is_true){
  4524 + th.setData({[txt]:1});
  4525 + return false;
  4526 + }
  4527 + th.setData({[txt]:num});
  4528 +
  4529 + },
  4530 +
  4531 +
  4532 +
4474 addNum:function (e) { 4533 addNum:function (e) {
4475 var th=this; 4534 var th=this;
4476 var idx=e.currentTarget.dataset.item; 4535 var idx=e.currentTarget.dataset.item;
@@ -4540,7 +4599,7 @@ Page({ @@ -4540,7 +4599,7 @@ Page({
4540 all_num += list_item.goods[j].goods_num; 4599 all_num += list_item.goods[j].goods_num;
4541 } 4600 }
4542 if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id ==gift_id && list_item.goods[j].prom_id == prom_id) { 4601 if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id ==gift_id && list_item.goods[j].prom_id == prom_id) {
4543 - all_limit_num += list_item.goods[j].goods_num; 4602 + all_limit_num += list_item.goods[j].limit_num;
4544 } 4603 }
4545 } 4604 }
4546 } 4605 }
@@ -4548,7 +4607,7 @@ Page({ @@ -4548,7 +4607,7 @@ Page({
4548 // 这里是保证所有的赠品部会超出 -- 4607 // 这里是保证所有的赠品部会超出 --
4549 if (discount.gift_storecount < all_num ) { 4608 if (discount.gift_storecount < all_num ) {
4550 wx.showToast({ 4609 wx.showToast({
4551 - title: "礼包库存不足", 4610 + title: "赠品库存不足",
4552 icon: 'none', 4611 icon: 'none',
4553 duration: 2000 4612 duration: 2000
4554 }); 4613 });
@@ -4662,10 +4721,13 @@ Page({ @@ -4662,10 +4721,13 @@ Page({
4662 var set_data = this.data.send_gf[gf_pickup_id][this.data.send_gf_index]; 4721 var set_data = this.data.send_gf[gf_pickup_id][this.data.send_gf_index];
4663 set_data.selected = 1; 4722 set_data.selected = 1;
4664 var txt9 = "cartlist[" + index + "].goods"; 4723 var txt9 = "cartlist[" + index + "].goods";
4665 - var txt1 = "send_gf[" + gf_pickup_id + "][" + this.data.send_gf_index + "]";  
4666 - th.setData({[txt9]: new_pk_list_goods, [txt1]: set_data}); 4724 +
  4725 + th.setData({[txt9]: new_pk_list_goods, send_gf: this.data.send_gf});
4667 this.data.old_cartlist[index].goods = new_pk_list_goods; 4726 this.data.old_cartlist[index].goods = new_pk_list_goods;
4668 4727
  4728 +
  4729 + console.log(this.data.send_gf,"----");
  4730 +
4669 th.calculatePrice(); 4731 th.calculatePrice();
4670 }else{ 4732 }else{
4671 var new_pk_list_goods=[]; 4733 var new_pk_list_goods=[];
pages/cart/cart2/cart2.wxml
@@ -202,7 +202,7 @@ @@ -202,7 +202,7 @@
202 data-pk="{{item.pickup_id}}" data-index="{{index}}" 202 data-pk="{{item.pickup_id}}" data-index="{{index}}"
203 bindtap="show_sele_gift" > 203 bindtap="show_sele_gift" >
204 <view class="flex ai_c"> 204 <view class="flex ai_c">
205 - <view class="circle">赠</view>{{iter.name}} 可选赠品{{iter.zp_num}}个 205 + <view class="circle1">赠</view>{{iter.name}} 可选赠品{{iter.zp_num}}个
206 </view> 206 </view>
207 207
208 <view class="flex ai_c" wx:if="{{iter.selected}}"> 208 <view class="flex ai_c" wx:if="{{iter.selected}}">
@@ -391,7 +391,7 @@ @@ -391,7 +391,7 @@
391 data-pk="{{bn_pick}}" data-index="{{index}}" 391 data-pk="{{bn_pick}}" data-index="{{index}}"
392 bindtap="show_sele_gift" > 392 bindtap="show_sele_gift" >
393 <view class="flex ai_c"> 393 <view class="flex ai_c">
394 - <view class="circle">赠</view>{{iter.name}} 可选赠品{{iter.zp_num}}个 394 + <view class="circle1">赠</view>{{iter.name}} 可选赠品{{iter.zp_num}}个
395 </view> 395 </view>
396 396
397 <view class="flex ai_c" wx:if="{{iter.selected}}"> 397 <view class="flex ai_c" wx:if="{{iter.selected}}">
@@ -726,9 +726,10 @@ @@ -726,9 +726,10 @@
726 </view> 726 </view>
727 <!-- top act_name --> 727 <!-- top act_name -->
728 <view class="flex gift_top_v ai_c fs30" style="padding-left: 70rpx"> 728 <view class="flex gift_top_v ai_c fs30" style="padding-left: 70rpx">
729 - {{gf_pr_name}},可以获赠一下任意{{zp_num}}件商 729 + {{gf_pr_name}},可任选{{zp_num}}件商品为赠
730 </view> 730 </view>
731 <!-- 赠品选择 --> 731 <!-- 赠品选择 -->
  732 + <scroll-view scroll-y="{{true}}" style="height:calc(100% - 300rpx);">
732 <view class="order-item" hidden="{{items.hide_div}}" data-item="{{idx}}" wx:for="{{giftsinfo}}" wx:for-item="items" wx:for-index="idx"> 733 <view class="order-item" hidden="{{items.hide_div}}" data-item="{{idx}}" wx:for="{{giftsinfo}}" wx:for-item="items" wx:for-index="idx">
733 734
734 <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected?items.selected:0}}" data-item="{{idx}}"> 735 <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected?items.selected:0}}" data-item="{{idx}}">
@@ -758,13 +759,14 @@ @@ -758,13 +759,14 @@
758 <view class="count"> 759 <view class="count">
759 <view bindtap="{{items.goods_num <= 1 ? '':'subNum'}}" class="sub fs28 {{items.goods_num <= 1 ? 'active':''}}" data-pitems="{{pidx}}" data-item="{{idx}}">一</view> 760 <view bindtap="{{items.goods_num <= 1 ? '':'subNum'}}" class="sub fs28 {{items.goods_num <= 1 ? 'active':''}}" data-pitems="{{pidx}}" data-item="{{idx}}">一</view>
760 <input class="goodadd" bindblur="valueToNum" data-item="{{idx}}" 761 <input class="goodadd" bindblur="valueToNum" data-item="{{idx}}"
761 - bindinput="refresh_input" type="number" value="{{items.goods_num}}"></input> 762 + bindinput="refresh_input" data-item="{{idx}}" type="number" value="{{items.goods_num}}"></input>
762 <view class="add" bindtap="addNum" data-item="{{idx}}">+</view> 763 <view class="add" bindtap="addNum" data-item="{{idx}}">+</view>
763 </view> 764 </view>
764 </view> 765 </view>
765 766
766 </view> 767 </view>
767 </view> 768 </view>
  769 + </scroll-view>
768 <!-- 确认选择 --> 770 <!-- 确认选择 -->
769 <view class="pay-for flex-vertical-between" style="bottom: 0"> 771 <view class="pay-for flex-vertical-between" style="bottom: 0">
770 <view></view> 772 <view></view>
pages/cart/cart_wk/cart_wk.js
@@ -376,6 +376,9 @@ Page({ @@ -376,6 +376,9 @@ Page({
376 dd.shipping_price = parseFloat(th.data.exp_price); 376 dd.shipping_price = parseFloat(th.data.exp_price);
377 dd.addressid = th.data.user_addr.address_id; 377 dd.addressid = th.data.user_addr.address_id;
378 } 378 }
  379 + if(getApp().globalData.scene){
  380 + dd.scene=getApp().globalData.scene;
  381 + }
379 382
380 var arr = []; 383 var arr = [];
381 arr.push(dd); 384 arr.push(dd);
pages/goods/goodsInfo/goodsInfo.js
@@ -801,6 +801,12 @@ Page({ @@ -801,6 +801,12 @@ Page({
801 this.wait_for_store_config(); 801 this.wait_for_store_config();
802 //先检验一下商品的活动情况 802 //先检验一下商品的活动情况
803 this.check_gd_prom_new(function () { 803 this.check_gd_prom_new(function () {
  804 +
  805 + if(ee.data.prom_type==8){
  806 + getApp().goto("/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+ee.data.gid+"&prom_id="+ee.data.prom_id);
  807 + return false;
  808 + }
  809 +
804 i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { 810 i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
805 failRollback: !0, 811 failRollback: !0,
806 success: function (t) { 812 success: function (t) {
@@ -839,6 +845,8 @@ Page({ @@ -839,6 +845,8 @@ Page({
839 }); 845 });
840 } 846 }
841 } 847 }
  848 +
  849 +
842 //动态获取商品名称 850 //动态获取商品名称
843 wx.setNavigationBarTitle({ 851 wx.setNavigationBarTitle({
844 title: t.data.data.goods_name, 852 title: t.data.data.goods_name,
@@ -1173,7 +1181,10 @@ Page({ @@ -1173,7 +1181,10 @@ Page({
1173 if (num < th.data.goodsInputNum) { 1181 if (num < th.data.goodsInputNum) {
1174 1182
1175 // getApp().my_warnning("活动库存不足!", 0, th); 1183 // getApp().my_warnning("活动库存不足!", 0, th);
1176 - wx.showToast({ title: '活动库存不足!', icon: 'none', }); 1184 + wx.showToast({
  1185 + title: '活动库存不足!',
  1186 + icon: 'none',
  1187 + });
1177 return false; 1188 return false;
1178 } else { 1189 } else {
1179 th.add_cart_func(t); 1190 th.add_cart_func(t);
@@ -1205,7 +1216,10 @@ Page({ @@ -1205,7 +1216,10 @@ Page({
1205 //---判断商品是否超出限购--- 1216 //---判断商品是否超出限购---
1206 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { 1217 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
1207 if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { 1218 if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) {
1208 - wx.showToast({ title: '超出商品限购', icon: 'none', }); 1219 + wx.showToast({
  1220 + title: '超出商品限购',
  1221 + icon: 'none',
  1222 + });
1209 // s.my_warnning('超出商品限购', 0, th); 1223 // s.my_warnning('超出商品限购', 0, th);
1210 return false; 1224 return false;
1211 } 1225 }
@@ -1428,7 +1442,10 @@ Page({ @@ -1428,7 +1442,10 @@ Page({
1428 if (res.data.data.pageData.length > 0) { 1442 if (res.data.data.pageData.length > 0) {
1429 var CanOutQty = res.data.data.pageData[0].CanOutQty; 1443 var CanOutQty = res.data.data.pageData[0].CanOutQty;
1430 if (CanOutQty < e.data.goodsInputNum) { 1444 if (CanOutQty < e.data.goodsInputNum) {
1431 - wx.showToast({ title: '库存不足!', icon: 'none', }); 1445 + wx.showToast({
  1446 + title: '库存不足!',
  1447 + icon: 'none',
  1448 + });
1432 return false; 1449 return false;
1433 // return s.my_warnning("库存不足!", 0, th); 1450 // return s.my_warnning("库存不足!", 0, th);
1434 } 1451 }
@@ -2013,7 +2030,10 @@ Page({ @@ -2013,7 +2030,10 @@ Page({
2013 var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); 2030 var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id);
2014 2031
2015 if (t + gd_buy_num > th.data.sele_g.viplimited) { 2032 if (t + gd_buy_num > th.data.sele_g.viplimited) {
2016 - wx.showToast({ title: '超出商品限购', icon: 'none', }); 2033 + wx.showToast({
  2034 + title: '超出商品限购',
  2035 + icon: 'none',
  2036 + });
2017 // s.my_warnning('超出商品限购', 0, th); 2037 // s.my_warnning('超出商品限购', 0, th);
2018 var num = th.data.sele_g.viplimited - gd_buy_num; 2038 var num = th.data.sele_g.viplimited - gd_buy_num;
2019 if (num < 0) num = 0; 2039 if (num < 0) num = 0;
@@ -2104,7 +2124,10 @@ Page({ @@ -2104,7 +2124,10 @@ Page({
2104 var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); 2124 var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id);
2105 2125
2106 if (t + gd_buy_num > th.data.sele_g.viplimited) { 2126 if (t + gd_buy_num > th.data.sele_g.viplimited) {
2107 - wx.showToast({ title: '超出商品限购', icon: 'none', }); 2127 + wx.showToast({
  2128 + title: '超出商品限购',
  2129 + icon: 'none',
  2130 + });
2108 // s.my_warnning('超出商品限购', 0, th); 2131 // s.my_warnning('超出商品限购', 0, th);
2109 var num = th.data.sele_g.viplimited - gd_buy_num; 2132 var num = th.data.sele_g.viplimited - gd_buy_num;
2110 if (num < 0) num = 0; 2133 if (num < 0) num = 0;
@@ -4321,7 +4344,10 @@ Page({ @@ -4321,7 +4344,10 @@ Page({
4321 th = e, 4344 th = e,
4322 o = this.data.sele_g; 4345 o = this.data.sele_g;
4323 if (o.store_count <= 0) { 4346 if (o.store_count <= 0) {
4324 - wx.showToast({ title: '库存已为空!', icon: 'none', }); 4347 + wx.showToast({
  4348 + title: '库存已为空!',
  4349 + icon: 'none',
  4350 + });
4325 return false; 4351 return false;
4326 // return s.my_warnning("库存已为空!", 0, th); 4352 // return s.my_warnning("库存已为空!", 0, th);
4327 }; 4353 };
@@ -5768,7 +5794,10 @@ Page({ @@ -5768,7 +5794,10 @@ Page({
5768 5794
5769 if (!th.data.only_pk && !th.data.def_pickpu_list) { 5795 if (!th.data.only_pk && !th.data.def_pickpu_list) {
5770 // getApp().confirmBox("门店库存不足", null, 25000, !1); 5796 // getApp().confirmBox("门店库存不足", null, 25000, !1);
5771 - wx.showToast({ title: '门店库存不足', icon: 'none', }); 5797 + wx.showToast({
  5798 + title: '门店库存不足',
  5799 + icon: 'none',
  5800 + });
5772 return false; 5801 return false;
5773 } 5802 }
5774 5803
pages/goods/goodsInfo/goodsInfo.wxml
@@ -505,7 +505,7 @@ @@ -505,7 +505,7 @@
505 <text class="tick lh2 pdr20" wx:if="{{item.past==1}}">包邮</text> 505 <text class="tick lh2 pdr20" wx:if="{{item.past==1}}">包邮</text>
506 <text class="tick lh2 pdr20" wx:if="{{item.intValue>0}}">送{{item.intValue}}积分</text> 506 <text class="tick lh2 pdr20" wx:if="{{item.intValue>0}}">送{{item.intValue}}积分</text>
507 <view class="tick lh2 pdr20" wx:if="{{item.couponId>0}}">送{{item.couponMoney}}元优惠券</view> 507 <view class="tick lh2 pdr20" wx:if="{{item.couponId>0}}">送{{item.couponMoney}}元优惠券</view>
508 - <view class="tick ellipsis-1x lh2" wx:if="{{item.gift_id}}">送商品{{tool.repl(item.goods_name)}}</view> 508 + <view class="tick ellipsis-1x lh2" wx:if="{{item.gift_id}}">送赠品</view>
509 <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.lb_id>0}}" data-id="{{item.lb_id}}" bindtap="viewLbDetails">送{{item.lbtitle}}</view> 509 <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.lb_id>0}}" data-id="{{item.lb_id}}" bindtap="viewLbDetails">送{{item.lbtitle}}</view>
510 <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.zxlb_id>0}}" data-id="{{item.zxlb_id}}" data-flag="1" bindtap="viewLbDetails">送{{item.zxlbtitle}}</view> 510 <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.zxlb_id>0}}" data-id="{{item.zxlb_id}}" data-flag="1" bindtap="viewLbDetails">送{{item.zxlbtitle}}</view>
511 </view> 511 </view>
pages/user/index/index.js
@@ -560,19 +560,22 @@ Page({ @@ -560,19 +560,22 @@ Page({
560 pageSize: 10 560 pageSize: 10
561 }, 561 },
562 success: function (ee) { 562 success: function (ee) {
563 - var recommend_list = ee.data.data.pageData;  
564 - if (recommend_list && recommend_list.length > 0) {  
565 - var dd = [...th_recommend_list, ...recommend_list];  
566 - e.setData({  
567 - recommend_list,  
568 - dd  
569 - });  
570 - e.data.currentPage++;  
571 - } else {  
572 - e.setData({  
573 - nomore: 1  
574 - });  
575 - } 563 +
  564 + if(ut.ajax_ok(ee)) {
  565 + var recommend_list = ee.data.data.pageData;
  566 + if (recommend_list && recommend_list.length > 0) {
  567 + var dd = [...th_recommend_list, ...recommend_list];
  568 + e.setData({
  569 + recommend_list,
  570 + dd
  571 + });
  572 + e.data.currentPage++;
  573 + } else {
  574 + e.setData({
  575 + nomore: 1
  576 + });
  577 + }
  578 + }
576 } 579 }
577 }) 580 })
578 }, 581 },
utils/filter.wxs
1 var filters = { 1 var filters = {
2 toFix: function (val, count) { 2 toFix: function (val, count) {
3 - if(!val){ 3 + if (!val) {
4 return parseFloat(0).toFixed(count); 4 return parseFloat(0).toFixed(count);
5 } 5 }
6 val = parseFloat(val); 6 val = parseFloat(val);
@@ -38,7 +38,7 @@ var filters = { @@ -38,7 +38,7 @@ var filters = {
38 } 38 }
39 return fm; 39 return fm;
40 }, 40 },
41 - 41 +
42 format_time2: function (ts, isFull) { 42 format_time2: function (ts, isFull) {
43 // 如果数值位数为1,则补0 43 // 如果数值位数为1,则补0
44 function appendZero(obj) { 44 function appendZero(obj) {
@@ -48,7 +48,7 @@ var filters = { @@ -48,7 +48,7 @@ var filters = {
48 return obj; 48 return obj;
49 } 49 }
50 }; 50 };
51 - 51 +
52 if (ts == null || ts == undefined || ts == '') return ""; 52 if (ts == null || ts == undefined || ts == '') return "";
53 var d = getDate(ts) 53 var d = getDate(ts)
54 var fm = [appendZero(d.getFullYear()), appendZero(d.getMonth() + 1), appendZero(d.getDate())].join('-'); 54 var fm = [appendZero(d.getFullYear()), appendZero(d.getMonth() + 1), appendZero(d.getDate())].join('-');
@@ -81,34 +81,34 @@ var filters = { @@ -81,34 +81,34 @@ var filters = {
81 } 81 }
82 } 82 }
83 }, 83 },
84 - 84 +
85 85
86 show_default: function (value, placeholder, multiple) { 86 show_default: function (value, placeholder, multiple) {
87 - if(typeof value === 'number') {  
88 - if(isNaN(value)) { 87 + if (typeof value === 'number') {
  88 + if (isNaN(value)) {
89 return placeholder || '-'; 89 return placeholder || '-';
90 - } else if(value === 0) { 90 + } else if (value === 0) {
91 return placeholder || '0'; 91 return placeholder || '0';
92 } else { 92 } else {
93 - if(multiple) { 93 + if (multiple) {
94 return value / multiple; 94 return value / multiple;
95 } else { 95 } else {
96 return value; 96 return value;
97 } 97 }
98 - };  
99 - } else if(value === '' || value === undefined || value === null) { 98 + };
  99 + } else if (value === '' || value === undefined || value === null) {
100 return placeholder || '-'; 100 return placeholder || '-';
101 } else { 101 } else {
102 return value; 102 return value;
103 } 103 }
104 }, 104 },
105 -  
106 - 105 +
  106 +
107 // 根据状态值返回相应的状态文字 107 // 根据状态值返回相应的状态文字
108 // num:状态数值, 108 // num:状态数值,
109 // arr: 状态文字数组, 109 // arr: 状态文字数组,
110 // 文字顺序必须跟状态数值对应 110 // 文字顺序必须跟状态数值对应
111 - status: function(num, arr) { 111 + status: function (num, arr) {
112 // var text = ''; 112 // var text = '';
113 // if(num == 0) { 113 // if(num == 0) {
114 // text = '未付款'; 114 // text = '未付款';
@@ -121,103 +121,103 @@ var filters = { @@ -121,103 +121,103 @@ var filters = {
121 // }; 121 // };
122 return arr[num]; 122 return arr[num];
123 }, 123 },
124 -  
125 -  
126 - in_arr: function(index, arr) {  
127 - if(arr.indexOf(index) != -1) { 124 +
  125 +
  126 + in_arr: function (index, arr) {
  127 + if (arr.indexOf(index) != -1) {
128 return true; 128 return true;
129 } else { 129 } else {
130 return false; 130 return false;
131 }; 131 };
132 }, 132 },
133 -  
134 - showByType: function(typeStr) { 133 +
  134 + showByType: function (typeStr) {
135 var index; 135 var index;
136 var newTypeArr = []; 136 var newTypeArr = [];
137 var typeStrArr = typeStr.split(','); 137 var typeStrArr = typeStr.split(',');
138 - typeStrArr.forEach(function(item) { 138 + typeStrArr.forEach(function (item) {
139 index = parseInt(item); 139 index = parseInt(item);
140 newTypeArr.push(index); 140 newTypeArr.push(index);
141 }); 141 });
142 // console.log('newTypeArr', newTypeArr); 142 // console.log('newTypeArr', newTypeArr);
143 return newTypeArr; 143 return newTypeArr;
144 }, 144 },
145 - 145 +
146 // 价格除以100 146 // 价格除以100
147 - price: function(val) {  
148 - return val / 100; 147 + price: function (val) {
  148 + return val / 100;
149 }, 149 },
150 -  
151 - div100: function(val) {  
152 - return val / 100; 150 +
  151 + div100: function (val) {
  152 + return val / 100;
153 }, 153 },
154 - 154 +
155 // 计算百分比, 不带百分号 155 // 计算百分比, 不带百分号
156 - percent: function(num1, num2) { 156 + percent: function (num1, num2) {
157 // console.log('百分比',Math.round(num1/num2 * 10000) / 100); 157 // console.log('百分比',Math.round(num1/num2 * 10000) / 100);
158 - return Math.round(num1/num2 * 10000) / 100;  
159 - },  
160 - 158 + return Math.round(num1 / num2 * 10000) / 100;
  159 + },
  160 +
161 // 计算差数 161 // 计算差数
162 - difference: function(num1, num2) {  
163 - if(!num1) num1 = 0;  
164 - if(!num2) num2 = 0;  
165 - if(num1 >= num2) { 162 + difference: function (num1, num2) {
  163 + if (!num1) num1 = 0;
  164 + if (!num2) num2 = 0;
  165 + if (num1 >= num2) {
166 return num1 - num2; 166 return num1 - num2;
167 } else { 167 } else {
168 return num2 - num1; 168 return num2 - num1;
169 }; 169 };
170 }, 170 },
171 - 171 +
172 // 计算乘积 172 // 计算乘积
173 - multiply: function(num1, num2) {  
174 - return num1 * 10000 * num2 / 10000; 173 + multiply: function (num1, num2) {
  174 + return num1 * 10000 * num2 / 10000;
175 }, 175 },
176 -  
177 - JSONStringify: function(val) { 176 +
  177 + JSONStringify: function (val) {
178 return JSON.stringify(val); 178 return JSON.stringify(val);
179 }, 179 },
180 - 180 +
181 // 循环列表计算数量 181 // 循环列表计算数量
182 - count: function(list) { 182 + count: function (list) {
183 var sum = 0; 183 var sum = 0;
184 - if(list && list.length != 0) {  
185 - list.forEach(function(item) { 184 + if (list && list.length != 0) {
  185 + list.forEach(function (item) {
186 sum += item.qty; 186 sum += item.qty;
187 }); 187 });
188 return sum; 188 return sum;
189 }; 189 };
190 }, 190 },
191 - 191 +
192 // 判断时间是否过期 192 // 判断时间是否过期
193 - isExpired: function(date) { 193 + isExpired: function (date) {
194 var mydate = getDate(date).getTime(); 194 var mydate = getDate(date).getTime();
195 var currentDate = getDate().getTime(); 195 var currentDate = getDate().getTime();
196 196
197 - if(currentDate >= mydate) { 197 + if (currentDate >= mydate) {
198 return true; 198 return true;
199 } else { 199 } else {
200 return false; 200 return false;
201 }; 201 };
202 }, 202 },
203 - 203 +
204 // 显示开始和结束日期 204 // 显示开始和结束日期
205 - showStartAndEndDate: function(o, val) {  
206 - 205 + showStartAndEndDate: function (o, val) {
  206 +
207 var dateType = o.date_type; 207 var dateType = o.date_type;
208 var currentDate = getDate().getTime(); 208 var currentDate = getDate().getTime();
209 var startDate, endDate, days, begin_days; 209 var startDate, endDate, days, begin_days;
210 -  
211 -  
212 - if(dateType === 0) {  
213 -  
214 - if(o.effective_days !== 0) { 210 +
  211 +
  212 + if (dateType === 0) {
  213 +
  214 + if (o.effective_days !== 0) {
215 days = (o.effective_days - 1) * 24 * 60 * 60 * 1000; 215 days = (o.effective_days - 1) * 24 * 60 * 60 * 1000;
216 endDate = filters.format_time2(currentDate + days); 216 endDate = filters.format_time2(currentDate + days);
217 currentDate = filters.format_time2(currentDate); 217 currentDate = filters.format_time2(currentDate);
218 return currentDate + '至' + endDate; 218 return currentDate + '至' + endDate;
219 } else { 219 } else {
220 - if(val) { 220 + if (val) {
221 days = (val - 1) * 24 * 60 * 60 * 1000; 221 days = (val - 1) * 24 * 60 * 60 * 1000;
222 endDate = filters.format_time2(currentDate + days); 222 endDate = filters.format_time2(currentDate + days);
223 currentDate = filters.format_time2(currentDate); 223 currentDate = filters.format_time2(currentDate);
@@ -227,27 +227,27 @@ var filters = { @@ -227,27 +227,27 @@ var filters = {
227 return currentDate + '至不限'; 227 return currentDate + '至不限';
228 } 228 }
229 } 229 }
230 - 230 +
231 }; 231 };
232 -  
233 - if(dateType === 1) { 232 +
  233 + if (dateType === 1) {
234 currentDate = filters.format_time2(currentDate); 234 currentDate = filters.format_time2(currentDate);
235 - if(o.begin_date && o.effective_date) { 235 + if (o.begin_date && o.effective_date) {
236 return o.begin_date + '至' + o.effective_date; 236 return o.begin_date + '至' + o.effective_date;
237 }; 237 };
238 - if(o.begin_date && !o.effective_date) { 238 + if (o.begin_date && !o.effective_date) {
239 return o.begin_date + '至不限'; 239 return o.begin_date + '至不限';
240 }; 240 };
241 - if(!o.begin_date && o.effective_date) { 241 + if (!o.begin_date && o.effective_date) {
242 return currentDate + '至' + o.effective_date; 242 return currentDate + '至' + o.effective_date;
243 }; 243 };
244 - if(!o.begin_date && !o.effective_date) { 244 + if (!o.begin_date && !o.effective_date) {
245 return currentDate + '至不限'; 245 return currentDate + '至不限';
246 }; 246 };
247 }; 247 };
248 -  
249 -  
250 - if(dateType === 2) { 248 +
  249 +
  250 + if (dateType === 2) {
251 // N天后开始 251 // N天后开始
252 begin_days = o.begin_days * 24 * 60 * 60 * 1000; 252 begin_days = o.begin_days * 24 * 60 * 60 * 1000;
253 // 有效天数 253 // 有效天数
@@ -256,11 +256,7 @@ var filters = { @@ -256,11 +256,7 @@ var filters = {
256 endDate = filters.format_time2(getDate(startDate).getTime() + days); 256 endDate = filters.format_time2(getDate(startDate).getTime() + days);
257 return startDate + '至' + endDate; 257 return startDate + '至' + endDate;
258 }; 258 };
259 -  
260 - },  
261 -  
262 -  
263 - 259 + },
264 }; 260 };
265 261
266 module.exports = { 262 module.exports = {