Commit bb6c123e205c2111015156778323bd460fe40424

Authored by yiren
1 parent abd0ca26

商家端优惠券购买分享

@@ -27,7 +27,7 @@ Page({ @@ -27,7 +27,7 @@ Page({
27 */ 27 */
28 onLoad(options) { 28 onLoad(options) {
29 this.setData({ 29 this.setData({
30 - use:JSON.parse(options.use), 30 + use:util.determine(options.use),
31 opt:{ 31 opt:{
32 id:options.id, 32 id:options.id,
33 name:options.name, 33 name:options.name,
@@ -58,7 +58,7 @@ Page({ @@ -58,7 +58,7 @@ Page({
58 }).then(res => { 58 }).then(res => {
59 if(res.data.length>0){ 59 if(res.data.length>0){
60 let detail=res.data[0]; 60 let detail=res.data[0];
61 - let exp_date=detail.exp_date?JSON.parse(detail.exp_date):''; 61 + let exp_date=util.determine(detail.exp_date);
62 let price = detail.price * 1; 62 let price = detail.price * 1;
63 let num = this.data.num * 1; 63 let num = this.data.num * 1;
64 this.setData({ 64 this.setData({
@@ -84,7 +84,18 @@ Page({ @@ -84,7 +84,18 @@ Page({
84 console.log(res.data); 84 console.log(res.data);
85 let that=this; 85 let that=this;
86 if(res.ret!='200'){ 86 if(res.ret!='200'){
87 - return util.toast(res.msg,'none'); 87 + wx.showToast({
  88 + title: res.msg,
  89 + duration: 1000,
  90 + icon:'none',
  91 + success: function () {
  92 + setTimeout(function () {
  93 + wx.reLaunch({
  94 + url: `/pages/customer/detail_owner_invitation_new?id=${that.data.opt.detail.oid}&hasInvitation=1&hasSellerShare=1&tplid=1`
  95 + })
  96 + }, 1000);
  97 + }
  98 + })
88 } 99 }
89 if(res.ret=='200'){ 100 if(res.ret=='200'){
90 console.log(res.ret); 101 console.log(res.ret);
@@ -271,7 +282,7 @@ Page({ @@ -271,7 +282,7 @@ Page({
271 }, 282 },
272 // 返回 283 // 返回
273 navEvent(){ 284 navEvent(){
274 - // 1 邀请函 2 提前点餐 285 + // 1 邀请函 2 提前点餐 3商家端分享
275 if(this.data.opt.types=='1'){ 286 if(this.data.opt.types=='1'){
276 return wx.reLaunch({ 287 return wx.reLaunch({
277 url: '/pages/customer/detail_owner_invitation_new?id='+this.data.opt.detail.oid, 288 url: '/pages/customer/detail_owner_invitation_new?id='+this.data.opt.detail.oid,
@@ -282,6 +293,11 @@ Page({ @@ -282,6 +293,11 @@ Page({
282 url: '/pack-cookbook/pages/success_new', 293 url: '/pack-cookbook/pages/success_new',
283 }) 294 })
284 } 295 }
  296 + if(this.data.opt.types=='3'){
  297 + return wx.reLaunch({
  298 + url: '/pages/reserve/index',
  299 + })
  300 + }
285 }, 301 },
286 /** 302 /**
287 * 生命周期函数--监听页面隐藏 303 * 生命周期函数--监听页面隐藏
@@ -178,9 +178,9 @@ Page({ @@ -178,9 +178,9 @@ Page({
178 long:reserev.seller.long, 178 long:reserev.seller.long,
179 } 179 }
180 }) 180 })
181 - console.log('reserevreserevreserevreserevreserev',reserev);  
182 - console.log('sellersellersellerseller',this.data.seller);  
183 - console.log('detaildetaildetaildetail',this.data.detail); 181 + console.log('reserev reserev',reserev);
  182 + console.log('seller seller',this.data.seller);
  183 + console.log('detail detail',this.data.detail);
184 setTimeout(() => { 184 setTimeout(() => {
185 this.getSellerTemplateConfFun(reserev.sid); 185 this.getSellerTemplateConfFun(reserev.sid);
186 this.getstaffinfo(res.data.uid) 186 this.getstaffinfo(res.data.uid)
@@ -190,7 +190,6 @@ Page({ @@ -190,7 +190,6 @@ Page({
190 }) 190 })
191 }, 191 },
192 getstaffinfo(uid){ 192 getstaffinfo(uid){
193 - console.log('Baseinfo__uid',uid);  
194 console.log('sellerid',this.data.detail.seller.id); 193 console.log('sellerid',this.data.detail.seller.id);
195 App.Activity.GetCustomerActivityBaseinfo({sellerid:this.data.detail.seller.id,uid}).then((json)=>{ 194 App.Activity.GetCustomerActivityBaseinfo({sellerid:this.data.detail.seller.id,uid}).then((json)=>{
196 if(json.ret==200){ 195 if(json.ret==200){
@@ -282,24 +281,27 @@ Page({ @@ -282,24 +281,27 @@ Page({
282 let data=res.data 281 let data=res.data
283 console.log('data',data); 282 console.log('data',data);
284 let home,chef,marketing,reserve,signboard,store,homeColor,coupon_data,priceInfo,certificate,scoreInfo,recharge_list,stringifyUse; 283 let home,chef,marketing,reserve,signboard,store,homeColor,coupon_data,priceInfo,certificate,scoreInfo,recharge_list,stringifyUse;
285 - chef = data.chef ? JSON.parse(data.chef) : '';  
286 - reserve = data.reserve ? JSON.parse(data.reserve) : '';  
287 - marketing = data.marketing ? JSON.parse(data.marketing) : '';  
288 - signboard = data.signboard ? JSON.parse(data.signboard) : '';  
289 - store = data.store ? JSON.parse(data.store) : '';  
290 - home = data.home ? JSON.parse(data.home) : '';  
291 - console.log('chef', chef);  
292 - console.log('reserve', reserve);  
293 - console.log('marketing', marketing);  
294 - console.log('signboard', signboard);  
295 - console.log('store', store);  
296 - console.log('home', home); 284 + chef = util.determine(data.chef);
  285 + reserve = util.determine(data.reserve);
  286 + marketing = util.determine(data.marketing);
  287 + signboard = util.determine(data.signboard);
  288 + store = util.determine(data.store);
  289 + home = util.determine(data.home);
297 if(marketing.coupon_data){ 290 if(marketing.coupon_data){
298 coupon_data=marketing.coupon_data; 291 coupon_data=marketing.coupon_data;
299 stringifyUse=JSON.stringify(marketing.coupon_data.use) 292 stringifyUse=JSON.stringify(marketing.coupon_data.use)
300 } 293 }
301 - console.log('coupon_data', coupon_data);  
302 - console.log('stringifyUse', stringifyUse); 294 + let obj={
  295 + chef,
  296 + reserve,
  297 + marketing,
  298 + signboard,
  299 + store,
  300 + home,
  301 + stringifyUse,
  302 + coupon_data
  303 + }
  304 + console.log('获取数据', {...obj});
303 if(marketing.is_recharge=='1' && marketing.recharge_data){ 305 if(marketing.is_recharge=='1' && marketing.recharge_data){
304 let recharge_data=marketing.recharge_data 306 let recharge_data=marketing.recharge_data
305 recharge_list=marketing.recharge_data.recharge_list 307 recharge_list=marketing.recharge_data.recharge_list
@@ -330,8 +332,8 @@ Page({ @@ -330,8 +332,8 @@ Page({
330 discount 332 discount
331 }) 333 })
332 } 334 }
333 - if(store && store.images.length>0) store.images =store.images?JSON.parse(store.images):'';  
334 - if(signboard && signboard.images) signboard.images = signboard.images?JSON.parse(signboard.images):''; 335 + if(store && store.images.length>0) store.images =util.determine(store.images);
  336 + if(signboard && signboard.images) signboard.images = util.determine(signboard.images);
335 if (marketing && marketing.is_online_book=='1' && marketing.is_transpond =='1') { 337 if (marketing && marketing.is_online_book=='1' && marketing.is_transpond =='1') {
336 this.setData({ 338 this.setData({
337 between: true 339 between: true
@@ -138,11 +138,23 @@ function parseDataValue(val) { @@ -138,11 +138,23 @@ function parseDataValue(val) {
138 } 138 }
139 } 139 }
140 140
  141 +// 判断是json 进行parse转化
  142 +function determine(str) {
  143 + if (typeof str == 'string') {
  144 + try {
  145 + var obj = JSON.parse(str);
  146 + return obj;
  147 + } catch (e) {
  148 + return str;
  149 + }
  150 + }
  151 +}
141 module.exports = { 152 module.exports = {
142 formatTime: formatTime, 153 formatTime: formatTime,
143 unixtoTime: unixtoTime, 154 unixtoTime: unixtoTime,
144 timetouUnix: timetouUnix, 155 timetouUnix: timetouUnix,
145 parseDataValue, 156 parseDataValue,
  157 + determine,
146 cgi: function (act) { 158 cgi: function (act) {
147 return uri.HOST__LINE + act //正式 159 return uri.HOST__LINE + act //正式
148 //return uri.HOST__TEST+act //测试 160 //return uri.HOST__TEST+act //测试