作者 刘朕

功能更新

@@ -47,14 +47,16 @@ App({ @@ -47,14 +47,16 @@ App({
47 // 滨海 47 // 滨海
48 var entrance_type = wx.getStorageSync("entrance_type"); 48 var entrance_type = wx.getStorageSync("entrance_type");
49 console.log(entrance_type); 49 console.log(entrance_type);
50 - if (entrance_type == '1' || url == '/getopenid/get' || url.indexOf('address') > -1 || url.indexOf('/wb/wb')>-1) { 50 + if (entrance_type == '1' || entrance_type == '0' || url == '/getopenid/get' || url.indexOf('/wb/wb')>-1) {
51 //劳保商城入口 51 //劳保商城入口
52 - // baseUrl = 'https://binhai.w.broing.cn/api';  
53 - baseUrl = 'http://binhai.shs.broing.cn/api' 52 + console.log('11111111111111111')
  53 + baseUrl = 'https://binhai.w.broing.cn/api';
  54 + // baseUrl = 'http://binhai.shs.broing.cn/api'
54 } else if (entrance_type == '2') { 55 } else if (entrance_type == '2') {
55 //工会商城入口 56 //工会商城入口
56 - // baseUrl = 'https://binhaigh.w.broing.cn/api';  
57 - baseUrl = 'http://gonghui.shs.broing.cn/api' 57 + console.log('@@@@@@@@@@@@@@@@@@@@@@')
  58 + baseUrl = 'https://binhaigh.w.broing.cn/api';
  59 + // baseUrl = 'http://gonghui.shs.broing.cn/api'
58 } else if (entrance_type == '3') { 60 } else if (entrance_type == '3') {
59 //办公入口 61 //办公入口
60 baseUrl = 'https://bgcb.w.broing.cn/api'; 62 baseUrl = 'https://bgcb.w.broing.cn/api';
@@ -79,7 +79,7 @@ Page({ @@ -79,7 +79,7 @@ Page({
79 // 修改地址 79 // 修改地址
80 editAddressFun(e) { 80 editAddressFun(e) {
81 wx.navigateTo({ 81 wx.navigateTo({
82 - url: '/pages/address/edit_address/edit_address?id=' + e.currentTarget.dataset.id, 82 + url: '/packageA/pages/address/edit_address/edit_address?id=' + e.currentTarget.dataset.id,
83 }) 83 })
84 }, 84 },
85 85
1 const app = getApp() 1 const app = getApp()
2 Page({ 2 Page({
3 3
4 - /**  
5 - * 页面的初始数据  
6 - */  
7 - data: {  
8 - success: false,  
9 - fail: false,  
10 - name: '',  
11 - choudanNum: 0,  
12 - addressId: 0,  
13 - tel: '',  
14 - area: '',  
15 - address: '',  
16 - cover_type: false,  
17 - total: '',  
18 - payMent: '',  
19 - orderPayMent: '',  
20 -  
21 - info: {  
22 - address: {  
23 - address: '',  
24 - area: '',  
25 - id: '',  
26 - tel: '',  
27 - name: ''  
28 - }  
29 -  
30 - }  
31 - },  
32 - //加减商品数量  
33 - num_change(e) {  
34 - let that = this  
35 - let num = Number(e.currentTarget.dataset.num)  
36 - console.log(num)  
37 - let type = e.currentTarget.dataset.type  
38 - let index = e.currentTarget.dataset.index  
39 - let id = e.currentTarget.dataset.id  
40 - let check = e.currentTarget.dataset.check  
41 - let coudan = this.data.coudan || []  
42 - let coudan_arr = this.data.coudan_arr || []  
43 - let price = e.currentTarget.dataset.price;  
44 - let price2 = e.currentTarget.dataset.price2; 4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + success: false,
  9 + fail: false,
  10 + name: '',
  11 + choudanNum:0,
  12 + addressId: 0,
  13 + tel: '',
  14 + area: '',
  15 + address: '',
  16 + cover_type: false,
  17 + total:'',
  18 +
  19 + info:{
  20 + address:{
  21 + address:'',
  22 + area:'',
  23 + id:'',
  24 + tel:'',
  25 + name:''
  26 + }
  27 +
  28 + }
  29 + },
  30 + //加减商品数量
  31 + num_change(e) {
  32 + let that = this
  33 + let num = Number(e.currentTarget.dataset.num)
  34 + console.log(num)
  35 + let type = e.currentTarget.dataset.type
  36 + let index = e.currentTarget.dataset.index
  37 + let id = e.currentTarget.dataset.id
  38 + let check = e.currentTarget.dataset.check
  39 + let coudan = this.data.coudan||[]
  40 + let coudan_arr = this.data.coudan_arr||[]
  41 + let price = e.currentTarget.dataset.price;
  42 + let price2 = e.currentTarget.dataset.price2;
  43 +
  44 + if (type == 1) {
  45 + if(this.data.info.choudan*100<(price*100)){
  46 + wx.showToast({
  47 + title: '当前剩余积分不足,请重新挑选',
  48 + icon:'none'
  49 + })
  50 + return
  51 + }
  52 + num++
  53 + } else {
  54 + num--
  55 + if (num < 0) {
  56 + num = 0;
  57 + return
  58 + }
  59 + }
45 60
46 - if (type == 1) {  
47 - if (this.data.info.choudan * 100 < (price * 100)) {  
48 - wx.showToast({  
49 - title: '当前剩余积分不足,请重新挑选',  
50 - icon: 'none'  
51 - })  
52 - return  
53 - }  
54 - num++  
55 - } else {  
56 - num--  
57 - if (num < 0) {  
58 - num = 0;  
59 - return  
60 - } 61 + if (num<1) {
  62 + coudan.forEach((item, index) => {
  63 + if (item.id == id) {
  64 + coudan.splice(index, 1)
  65 + coudan_arr.splice(index, 1)
61 } 66 }
62 -  
63 - if (num < 1) {  
64 - coudan.forEach((item, index) => {  
65 - if (item.id == id) {  
66 - coudan.splice(index, 1)  
67 - coudan_arr.splice(index, 1)  
68 - }  
69 - })  
70 - } else {  
71 - if (type == 1 && num == 1) { 67 + })
  68 + } else {
  69 + if(type==1&&num==1){
72 //选中 70 //选中
73 - coudan.push({  
74 - id: id,  
75 - num: num  
76 - })  
77 - coudan_arr.push({  
78 - id: id,  
79 - num: num,  
80 - price: Number(price),  
81 - price2: Number(price2)  
82 - })  
83 - } else {  
84 - coudan.forEach((item, index) => {  
85 - if (item.id == id) {  
86 - item.num = num  
87 - coudan_arr[index].num = num  
88 - }  
89 - })  
90 - }  
91 -  
92 - }  
93 - that.setData({  
94 - coudan: coudan,  
95 - coudan_arr: coudan_arr,  
96 - [`info.coudanProduct[${index}].num`]: num  
97 - // [`info.coudanProduct[${index}].check`]: check  
98 - })  
99 - this.get_choudan()  
100 - },  
101 - // 计算凑单费用  
102 - get_choudan() {  
103 - let coudan_arr = this.data.coudan_arr  
104 - let choudan_money = 0;  
105 - let num = 0  
106 - for (let obj of coudan_arr) {  
107 - console.log(obj)  
108 - console.log(obj.price2)  
109 - if (obj.price2 != null) {  
110 - console.log(111)  
111 - choudan_money = (obj.price2 * 100 * obj.num) / 100 + choudan_money  
112 - } else {  
113 - console.log(222)  
114 - choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money 71 + coudan.push({
  72 + id: id,
  73 + num: num
  74 + })
  75 + coudan_arr.push({
  76 + id: id,
  77 + num: num,
  78 + price: Number(price),
  79 + price2:Number(price2)
  80 + })
  81 + }else{
  82 + coudan.forEach((item, index) => {
  83 + if (item.id == id) {
  84 + item.num = num
  85 + coudan_arr[index].num = num
115 } 86 }
116 - num = num + obj.num 87 + })
117 } 88 }
118 89
119 - this.setData({  
120 - choudan_money: choudan_money * 100,  
121 - choudanNum: num,  
122 - 'info.choudan': this.data.info.syjf - choudan_money  
123 - // choudan_money: Math.floor(choudan_money* 100) / 100  
124 - })  
125 - },  
126 - show_cover() {  
127 - let that = this  
128 - if (!that.data.cover_type) {  
129 - if (that.data.info.status == 0) {  
130 - that.setData({  
131 - fail: true  
132 - })  
133 - return  
134 - }  
135 - if (!that.data.info.address) {  
136 - wx.showToast({  
137 - title: '请添加地址',  
138 - icon: 'none',  
139 - duration: 1000  
140 - })  
141 - return  
142 - }  
143 - }  
144 - that.setData({  
145 - cover_type: !this.data.cover_type  
146 - })  
147 - },  
148 - // 去添加地址  
149 - add_address() {  
150 - wx.navigateTo({  
151 - url: '/pages/address/address',  
152 - })  
153 - },  
154 - 90 + }
  91 + that.setData({
  92 + coudan: coudan,
  93 + coudan_arr: coudan_arr,
  94 + [`info.coudanProduct[${index}].num`]: num
  95 + // [`info.coudanProduct[${index}].check`]: check
  96 + })
  97 + this.get_choudan()
  98 + },
  99 + // 计算凑单费用
  100 + get_choudan() {
  101 + let coudan_arr = this.data.coudan_arr
  102 + let choudan_money = 0;
  103 + let num = 0
  104 + for (let obj of coudan_arr) {
  105 + console.log(obj)
  106 + console.log(obj.price2)
  107 + if (obj.price2!= null) {
  108 + console.log(111)
  109 + choudan_money = (obj.price2 * 100 * obj.num) / 100 + choudan_money
  110 + } else {
  111 + console.log(222)
  112 + choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money
  113 + }
  114 + num = num+obj.num
  115 + }
155 116
156 - //选择凑单商品  
157 - chooseGoods(e) {  
158 - // coudan 凑单商品组成的数组  
159 - // coudan_type 凑单的状态 可能废弃  
160 - let that = this  
161 - let coudan = this.data.coudan ? this.data.coudan : []  
162 - let coudan_arr = this.data.coudan_arr ? this.data.coudan_arr : []  
163 - let check = e.currentTarget.dataset.check  
164 - let num = e.currentTarget.dataset.num  
165 - let index = e.currentTarget.dataset.index  
166 - let id = e.currentTarget.dataset.id  
167 - let price = e.currentTarget.dataset.price;  
168 - let price2 = e.currentTarget.dataset.price2;  
169 - if (check) {  
170 - check = 0  
171 - coudan.forEach((item, index) => {  
172 - if (item.id == id) {  
173 - coudan.splice(index, 1)  
174 - coudan_arr.splice(index, 1)  
175 - }  
176 - })  
177 - } else {  
178 - check = 1  
179 - //选中  
180 - coudan.push({  
181 - id: id,  
182 - num: num  
183 - })  
184 - coudan_arr.push({  
185 - id: id,  
186 - num: num,  
187 - price: Number(price),  
188 - price2: Number(price2)  
189 - })  
190 - } 117 + this.setData({
  118 + choudan_money: choudan_money*100,
  119 + choudanNum:num,
  120 + 'info.choudan': this.data.info.syjf - choudan_money
  121 + // choudan_money: Math.floor(choudan_money* 100) / 100
  122 + })
  123 + },
  124 + show_cover() {
  125 + let that = this
  126 + if (!that.data.cover_type) {
  127 + if (that.data.info.status == 0) {
191 that.setData({ 128 that.setData({
192 - coudan: coudan,  
193 - coudan_arr: coudan_arr,  
194 - [`info.coudanProduct[${index}].check`]: check  
195 - })  
196 - that.get_choudan()  
197 - },  
198 -  
199 - //获取页面信息  
200 - get_info(type, info, id) {  
201 - let that = this  
202 - let url = type == 4 ? app.interface.prev_pay : app.interface.now_prev_pay  
203 - let params = {  
204 - info: info  
205 - }  
206 - app.post(url, params).then((res) => {  
207 - console.log('99999', res, Number(res.msg.total))  
208 - res.msg.syjf = res.msg.choudan - res.msg.yunfei  
209 - let a = (res.msg.choudan - res.msg.yunfei).toFixed(2)  
210 - if (a < 0) {  
211 - a = 0  
212 - }  
213 - res.msg.choudan = a  
214 - res.msg.total = Number(res.msg.total * 100)  
215 - res.msg.yunfei = Number(res.msg.yunfei * 100)  
216 -  
217 - let total = (res.msg.total + res.msg.yunfei).toFixed("1");  
218 - console.log(total)  
219 -  
220 - that.setData({  
221 - info: res.msg,  
222 - total: total  
223 - })  
224 - console.log('9988756', that.data.info)  
225 - 129 + fail: true
226 }) 130 })
227 - },  
228 -  
229 -  
230 - //获取页面信息  
231 - get_youfei(id) {  
232 - let that = this  
233 - let url = that.data.type == 4 ? app.interface.youfei1 : app.interface.youfei  
234 - let params = {  
235 - info: that.data.params,  
236 - address_id: id  
237 - }  
238 - app.post(url, params).then((res) => {  
239 - that.setData({  
240 - "info.yunfei": Number(res.msg.yunfei) * 100  
241 - }) 131 + return
  132 + }
  133 + if (!that.data.info.address) {
  134 + wx.showToast({
  135 + title: '请添加地址',
  136 + icon: 'none',
  137 + duration: 1000
242 }) 138 })
243 - },  
244 - // 支付失败弹窗关闭  
245 - payFail() {  
246 - this.setData({  
247 - fail: false  
248 - })  
249 - },  
250 - // 混合支付  
251 - mixedPay() {  
252 - let that = this  
253 - let url = app.interface.orderMixed  
254 - let params = {  
255 - order_odd: that.data.orderPayMent,  
256 - money: that.data.payMent 139 + return
  140 + }
  141 + }
  142 + that.setData({
  143 + cover_type: !this.data.cover_type
  144 + })
  145 + },
  146 + // 去添加地址
  147 + add_address() {
  148 + wx.navigateTo({
  149 + url: '/packageA/pages/address/address',
  150 + })
  151 + },
  152 +
  153 +
  154 + //选择凑单商品
  155 + chooseGoods(e) {
  156 + // coudan 凑单商品组成的数组
  157 + // coudan_type 凑单的状态 可能废弃
  158 + let that = this
  159 + let coudan = this.data.coudan ? this.data.coudan : []
  160 + let coudan_arr = this.data.coudan_arr ? this.data.coudan_arr : []
  161 + let check = e.currentTarget.dataset.check
  162 + let num = e.currentTarget.dataset.num
  163 + let index = e.currentTarget.dataset.index
  164 + let id = e.currentTarget.dataset.id
  165 + let price = e.currentTarget.dataset.price;
  166 + let price2 = e.currentTarget.dataset.price2;
  167 + if (check) {
  168 + check = 0
  169 + coudan.forEach((item, index) => {
  170 + if (item.id == id) {
  171 + coudan.splice(index, 1)
  172 + coudan_arr.splice(index, 1)
257 } 173 }
258 - app.post(url, params).then((res) => {  
259 - wx.requestPayment({  
260 - timeStamp: res.data.timestamp,  
261 - nonceStr: res.data.nonceStr,  
262 - package: res.data.package,  
263 - signType: 'MD5',  
264 - paySign: res.data.paySign,  
265 - success(res) {  
266 - console.log(res,'支付成功')  
267 - that.setData({  
268 - fail: false  
269 - })  
270 - wx.showToast({  
271 - title: '支付成功',  
272 - })  
273 - },  
274 - fail(res) {  
275 - console.log(res,'支付失败')  
276 - }  
277 - }) 174 + })
  175 + } else {
  176 + check = 1
  177 + //选中
  178 + coudan.push({
  179 + id: id,
  180 + num: num
  181 + })
  182 + coudan_arr.push({
  183 + id: id,
  184 + num: num,
  185 + price: Number(price),
  186 + price2:Number(price2)
  187 + })
  188 + }
  189 + that.setData({
  190 + coudan: coudan,
  191 + coudan_arr: coudan_arr,
  192 + [`info.coudanProduct[${index}].check`]: check
  193 + })
  194 + that.get_choudan()
  195 + },
  196 +
  197 + //获取页面信息
  198 + get_info(type, info, id) {
  199 + let that = this
  200 + let url = type == 4 ? app.interface.prev_pay : app.interface.now_prev_pay
  201 + let params = {
  202 + info: info
  203 + }
  204 + app.post(url, params).then((res) => {
  205 + console.log('99999', res, Number(res.msg.total))
  206 + res.msg.syjf = res.msg.choudan - res.msg.yunfei
  207 + res.msg.choudan = res.msg.choudan - res.msg.yunfei
  208 + res.msg.total = Number(res.msg.total * 100)
  209 + res.msg.yunfei = Number(res.msg.yunfei * 100)
  210 +
  211 + let total = (res.msg.total + res.msg.yunfei).toFixed("1");
  212 + console.log(total)
  213 +
  214 + that.setData({
  215 + info: res.msg,
  216 + total:total
  217 +
  218 + })
  219 +
  220 + console.log('9988756', that.data.info)
  221 +
  222 + })
  223 + },
  224 +
  225 +
  226 + //获取页面信息
  227 + get_youfei(id) {
  228 + let that = this
  229 + let url = that.data.type == 4 ? app.interface.youfei1 : app.interface.youfei
  230 + let params = {
  231 + info: that.data.params,
  232 + address_id: id
  233 + }
  234 + app.post(url, params).then((res) => {
  235 + that.setData({
  236 + "info.yunfei": Number(res.msg.yunfei)*100
  237 + })
  238 + })
  239 + },
  240 +
  241 +
  242 + //点击支付
  243 + submit() {
  244 + let that = this
  245 + let list = that.data.info.products
  246 + let coudan = that.data.coudan
  247 + let info = []
  248 + if (that.data.type == 4) {
  249 + for (let obj of list) {
  250 + info.push({
  251 + id: obj.product.id,
  252 + num: obj.product.num
278 }) 253 })
279 - },  
280 - //点击支付  
281 - submit() {  
282 - let that = this  
283 - let list = that.data.info.products  
284 - let coudan = that.data.coudan  
285 - let info = []  
286 - if (that.data.type == 4) {  
287 - for (let obj of list) {  
288 - info.push({  
289 - id: obj.product.id,  
290 - num: obj.product.num  
291 - })  
292 - }  
293 - } else {  
294 - for (let obj of list) {  
295 - info.push({  
296 - id: obj.id,  
297 - num: obj.num  
298 - })  
299 - }  
300 - }  
301 - if (coudan && coudan.length > 0) {  
302 - info = info.concat(coudan)  
303 - }  
304 - let url = app.interface.now_add  
305 - let params = {  
306 - address: that.data.info.address.id,  
307 - info: JSON.stringify(info)  
308 - }  
309 - app.post(url, params).then((res) => {  
310 - that.setData({  
311 - cover_type: false  
312 - })  
313 - that.setData({  
314 - orderPayMent: res.msg  
315 - })  
316 - that.order_pay(res.msg) 254 + }
  255 + } else {
  256 + for (let obj of list) {
  257 + info.push({
  258 + id: obj.id,
  259 + num: obj.num
317 }) 260 })
318 - },  
319 -  
320 - //订单支付  
321 - order_pay(order_odd) {  
322 - let that = this  
323 - let url = app.interface.order_pay  
324 - let params = {  
325 - order_odd: order_odd  
326 - }  
327 - app.post(url, params).then((res) => {  
328 - this.setData({  
329 - order: res.msg  
330 - })  
331 - if (res.msg.message == "支付成功") {  
332 - // wx.showToast({  
333 - // title: '购买成功',  
334 - // icon:'none'  
335 - // })  
336 - this.setData({  
337 - success: true  
338 - })  
339 - } else if (res.msg.message == "余额不足") {  
340 - this.setData({  
341 - fail: true  
342 - })  
343 - let payMents = (that.data.info.total + that.data.info.yunfei) / 100 - that.data.order.syjf  
344 - that.setData({  
345 - payMent: payMents.toFixed(2)  
346 - })  
347 - console.log(payMents, 'payMent')  
348 - } 261 + }
  262 + }
  263 + if (coudan && coudan.length > 0) {
  264 + info = info.concat(coudan)
  265 + }
  266 + let url = app.interface.now_add
  267 + let params = {
  268 + address: that.data.info.address.id,
  269 + info: JSON.stringify(info)
  270 + }
  271 + app.post(url, params).then((res) => {
  272 + that.setData({
  273 + cover_type: false
  274 + })
  275 + that.order_pay(res.msg)
  276 + })
  277 + },
  278 +
  279 + //订单支付
  280 + order_pay(order_odd) {
  281 + let url = app.interface.order_pay
  282 + let params = {
  283 + order_odd: order_odd
  284 + }
  285 + app.post(url, params).then((res) => {
  286 + this.setData({
  287 + order: res.msg
  288 + })
  289 + if (res.msg.message == "支付成功") {
  290 + // wx.showToast({
  291 + // title: '购买成功',
  292 + // icon:'none'
  293 + // })
  294 + this.setData({
  295 + success: true
349 }) 296 })
350 - },  
351 - /**  
352 - * 生命周期函数--监听页面加载  
353 - */  
354 - onLoad: function (options) {  
355 - console.log(options) 297 + } else if (res.msg.message == "余额不足") {
356 this.setData({ 298 this.setData({
357 - type: options.type,  
358 - params: options.info 299 + fail: true
359 }) 300 })
360 - this.get_info(options.type, options.info, options.id)  
361 - },  
362 -  
363 -  
364 - /**  
365 - * 生命周期函数--监听页面初次渲染完成  
366 - */  
367 - onReady: function () {  
368 -  
369 - },  
370 -  
371 - /**  
372 - * 生命周期函数--监听页面显示  
373 - */  
374 - onShow: function () {  
375 -  
376 - let pages = getCurrentPages();  
377 -  
378 - let currPage = pages[pages.length - 1]  
379 - console.log('887766554', currPage.data.id)  
380 - if (currPage.data.id) {  
381 - console.log('4778785', this.data.info)  
382 -  
383 - this.setData({  
384 - "info.address.address": currPage.data.address,  
385 - "info.address.area": currPage.data.area,  
386 - "info.address.id": currPage.data.id,  
387 - "info.address.tel": currPage.data.tel,  
388 - "info.address.name": currPage.data.name  
389 - })  
390 - console.log(this.data.info)  
391 - console.log(currPage.data.address)  
392 - this.get_youfei(currPage.data.id)  
393 - }  
394 - // if (wx.getStorageSync('no_address')) {  
395 - // wx.setStorageSync('no_address', false)  
396 - // this.setData({  
397 - // "info.address": null  
398 - // })  
399 - // } 301 + }
  302 + })
  303 + },
  304 + /**
  305 + * 生命周期函数--监听页面加载
  306 + */
  307 + onLoad: function(options) {
  308 + console.log(options)
  309 + this.setData({
  310 + type: options.type,
  311 + params: options.info
  312 + })
  313 + this.get_info(options.type, options.info, options.id)
  314 + },
  315 +
  316 +
  317 + /**
  318 + * 生命周期函数--监听页面初次渲染完成
  319 + */
  320 + onReady: function() {
  321 +
  322 + },
  323 +
  324 + /**
  325 + * 生命周期函数--监听页面显示
  326 + */
  327 + onShow: function() {
  328 +
  329 + let pages = getCurrentPages();
  330 +
  331 + let currPage = pages[pages.length - 1]
  332 + console.log('887766554',currPage.data.id)
  333 + if (currPage.data.id) {
  334 + console.log('4778785',this.data.info)
  335 +
  336 + this.setData({
  337 + "info.address.address": currPage.data.address,
  338 + "info.address.area": currPage.data.area,
  339 + "info.address.id": currPage.data.id,
  340 + "info.address.tel": currPage.data.tel,
  341 + "info.address.name": currPage.data.name
  342 + })
  343 + console.log(this.data.info)
  344 + console.log(currPage.data.address)
  345 + this.get_youfei(currPage.data.id)
  346 + }
  347 + // if (wx.getStorageSync('no_address')) {
  348 + // wx.setStorageSync('no_address', false)
  349 + // this.setData({
  350 + // "info.address": null
  351 + // })
  352 + // }
400 353
401 - }, 354 + },
402 355
403 - /**  
404 - * 生命周期函数--监听页面隐藏  
405 - */  
406 - onHide: function () { 356 + /**
  357 + * 生命周期函数--监听页面隐藏
  358 + */
  359 + onHide: function() {
407 360
408 - }, 361 + },
409 362
410 - /**  
411 - * 生命周期函数--监听页面卸载  
412 - */  
413 - onUnload: function () { 363 + /**
  364 + * 生命周期函数--监听页面卸载
  365 + */
  366 + onUnload: function() {
414 367
415 - }, 368 + },
416 369
417 - /**  
418 - * 页面相关事件处理函数--监听用户下拉动作  
419 - */  
420 - onPullDownRefresh: function () { 370 + /**
  371 + * 页面相关事件处理函数--监听用户下拉动作
  372 + */
  373 + onPullDownRefresh: function() {
421 374
422 - }, 375 + },
423 376
424 - /**  
425 - * 页面上拉触底事件的处理函数  
426 - */  
427 - onReachBottom: function () { 377 + /**
  378 + * 页面上拉触底事件的处理函数
  379 + */
  380 + onReachBottom: function() {
428 381
429 - }, 382 + },
430 383
431 - /**  
432 - * 用户点击右上角分享  
433 - */  
434 - onShareAppMessage: function () { 384 + /**
  385 + * 用户点击右上角分享
  386 + */
  387 + onShareAppMessage: function() {
435 388
436 - } 389 + }
437 }) 390 })
1 <view class="content"> 1 <view class="content">
2 - <!-- 地址信息 -->  
3 - <view class="address_box" wx:if="{{info.address}}" bindtap="add_address">  
4 - <view class="name">{{info.address.name}}  
5 - <text>{{info.address.tel}}</text>  
6 - <text>{{info.address.b_tel||""}}</text>  
7 - </view>  
8 - <view class="address">  
9 - <image class="tips_img" src="/images/icon_54.png" />  
10 - <view>{{info.address.area}}{{info.address.address}}</view>  
11 - </view>  
12 - <image src="/images/icon_41.png" class="youjiantou" />  
13 - </view>  
14 -  
15 - <view class="on_address" wx:else bindtap="add_address">  
16 - <image src="/images/icon_46.png" />  
17 - <view>暂无收货地址,  
18 - <text>去添加</text>  
19 - </view> 2 + <!-- 地址信息 -->
  3 + <view class="address_box" wx:if="{{info.address}}" bindtap="add_address">
  4 + <view class="name">{{info.address.name}}
  5 + <text>{{info.address.tel}}</text>
  6 + <text>{{info.address.b_tel||""}}</text>
20 </view> 7 </view>
21 - <view class="line">  
22 - <image src="/images/line.png" /> 8 + <view class="address">
  9 + <image class="tips_img" src="/images/icon_54.png" />
  10 + <view>{{info.address.area}}{{info.address.address}}</view>
23 </view> 11 </view>
  12 + <image src="/images/icon_41.png" class="youjiantou" />
  13 + </view>
24 14
25 - <view class="content">  
26 - <shop_item list="{{info.products}}" type="{{type}}" />  
27 - <view class='recommend' wx:if="{{info.coudanProduct.length>0}}">  
28 - <view class='re_one'>*您支付后还剩{{info.choudan}}积分为您推荐了以下凑单产品!</view>  
29 - <scroll-view class='re_goods' scroll-x scroll-left="0">  
30 - <view class='re_item' wx:for='{{info.coudanProduct}}' wx:key='index' data-index="{{index}}" data-id="{{item.id}}" data-num="{{item.num?item.num:1}}" data-check='{{item.check}}' data-price='{{item.price}}' data-price2="{{item.price2}}">  
31 - <view class='re_re_item {{item.check?"active":""}}'>  
32 - <view class='triangle' wx:if='{{item.check}}'>  
33 - <image src='/images/bingo.png' class='bingo'></image>  
34 - </view>  
35 - <view class='re_re_img'>  
36 - <image src='{{item.images[0]}}' mode='aspectFill'></image>  
37 - </view>  
38 - <view class='re_bottom'>  
39 - <view class='re_re_name'>{{item.name}}</view>  
40 - <view class='re_re_score' wx:if="{{item.price!=null}}">{{item.price2}}积分</view>  
41 - <view class='re_re_score' wx:else>{{item.price}}积分</view>  
42 - </view>  
43 -  
44 - <!-- 数量操作 -->  
45 - <view class="num_box">  
46 - <image class="num_btn" src="/images/reduce.png" data-check='{{item.check}}' wx:if="{{item.num}}" data-index="{{index}}" data-id="{{item.id}}" data-type="0" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />  
47 - <text wx:if="{{item.num}}">{{item.num?item.num:0}}</text>  
48 - <image class="num_btn" src="/images/add.png" data-check='{{item.check}}' data-index="{{index}}" data-id="{{item.id}}" data-type="1" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />  
49 - </view>  
50 - </view>  
51 - </view>  
52 - </scroll-view>  
53 - </view> 15 + <view class="on_address" wx:else bindtap="add_address">
  16 + <image src="/images/icon_46.png" />
  17 + <view>暂无收货地址,
  18 + <text>去添加</text>
  19 + </view>
  20 + </view>
  21 + <view class="line">
  22 + <image src="/images/line.png" />
  23 + </view>
54 24
55 - <view class='three'>  
56 - <view class='mask_two'>  
57 - <view>订单编号</view>  
58 - <view class='score'>{{info.order_odd}}</view> 25 + <view class="content">
  26 + <shop_item list="{{info.products}}" type="{{type}}" />
  27 + <view class='recommend' wx:if="{{info.coudanProduct.length>0}}">
  28 + <view class='re_one'>*您支付后还剩{{info.choudan}}积分为您推荐了以下凑单产品!</view>
  29 + <scroll-view class='re_goods' scroll-x scroll-left="0">
  30 + <view class='re_item' wx:for='{{info.coudanProduct}}' wx:key='index' data-index="{{index}}" data-id="{{item.id}}" data-num="{{item.num?item.num:1}}" data-check='{{item.check}}' data-price='{{item.price}}' data-price2="{{item.price2}}">
  31 + <view class='re_re_item {{item.check?"active":""}}'>
  32 + <view class='triangle' wx:if='{{item.check}}'>
  33 + <image src='/images/bingo.png' class='bingo'></image>
59 </view> 34 </view>
60 -  
61 - <view class='mask_two'>  
62 - <view>创建时间</view>  
63 - <view class='score'>{{info.date}}</view> 35 + <view class='re_re_img'>
  36 + <image src='{{item.images[0]}}' mode='aspectFill'></image>
  37 + </view>
  38 + <view class='re_bottom'>
  39 + <view class='re_re_name'>{{item.name}}</view>
  40 + <view class='re_re_score'wx:if="{{item.price!=null}}">{{item.price2}}积分</view>
  41 + <view class='re_re_score' wx:else>{{item.price}}积分</view>
64 </view> 42 </view>
65 43
66 - <view class='mask_two'>  
67 - <view>邮费</view>  
68 - <view class='score' style="color:rgba(242, 0, 0, 1)">{{info.yunfei/100}}积分</view> 44 + <!-- 数量操作 -->
  45 + <view class="num_box">
  46 + <image class="num_btn" src="/images/reduce.png" data-check='{{item.check}}' wx:if="{{item.num}}" data-index="{{index}}" data-id="{{item.id}}" data-type="0" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
  47 + <text wx:if="{{item.num}}" >{{item.num?item.num:0}}</text>
  48 + <image class="num_btn" src="/images/add.png" data-check='{{item.check}}' data-index="{{index}}" data-id="{{item.id}}" data-type="1" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
69 </view> 49 </view>
  50 + </view>
70 </view> 51 </view>
  52 + </scroll-view>
71 </view> 53 </view>
  54 +
  55 + <view class='three'>
  56 + <view class='mask_two'>
  57 + <view>订单编号</view>
  58 + <view class='score'>{{info.order_odd}}</view>
  59 + </view>
  60 +
  61 + <view class='mask_two'>
  62 + <view>创建时间</view>
  63 + <view class='score'>{{info.date}}</view>
  64 + </view>
  65 +
  66 + <view class='mask_two'>
  67 + <view>邮费</view>
  68 + <view class='score' style="color:rgba(242, 0, 0, 1)">{{info.yunfei/100}}积分</view>
  69 + </view>
  70 + </view>
  71 + </view>
72 </view> 72 </view>
73 73
74 <view class="footer"> 74 <view class="footer">
75 - <view class="submit" catchtap="show_cover">提交</view>  
76 - <view class="jifen"> 合计:  
77 - <!-- <text>{{choudan_money?choudan_money + info.total + info.yunfei*100/100: info.total + info.yunfei*100/100}}积分</text> -->  
78 - <text>{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</text>  
79 - </view>  
80 - <view class="num">共{{info.totalnum + choudanNum}}件</view> 75 + <view class="submit" catchtap="show_cover">提交</view>
  76 + <view class="jifen"> 合计:
  77 + <!-- <text>{{choudan_money?choudan_money + info.total + info.yunfei*100/100: info.total + info.yunfei*100/100}}积分</text> -->
  78 + <text>{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</text>
  79 + </view>
  80 + <view class="num">共{{info.totalnum + choudanNum}}件</view>
81 </view> 81 </view>
82 -<concat /> 82 +<concat/>
83 83
84 <!-- 支付成功弹框开始 --> 84 <!-- 支付成功弹框开始 -->
85 <view class='success_mask' wx:if='{{success}}'> 85 <view class='success_mask' wx:if='{{success}}'>
86 - <view class='success_diceng'>  
87 - <view class='success_one'>  
88 - <image src='/images/success.png'></image>  
89 - </view>  
90 - <view class='success_font'>支付成功</view>  
91 - <navigator class='success_confirm_btn' open-type="navigateBack">确定</navigator> 86 + <view class='success_diceng'>
  87 + <view class='success_one'>
  88 + <image src='/images/success.png'></image>
92 </view> 89 </view>
  90 + <view class='success_font'>支付成功</view>
  91 + <navigator class='success_confirm_btn' open-type="navigateBack">确定</navigator>
  92 + </view>
93 </view> 93 </view>
94 <!-- 支付成功弹框结束 --> 94 <!-- 支付成功弹框结束 -->
95 <!-- 支付失败弹框开始 --> 95 <!-- 支付失败弹框开始 -->
96 -<!-- <view class='success_mask' wx:if='{{fail}}'> 96 +<view class='success_mask' wx:if='{{fail}}'>
97 <view class='success_diceng'> 97 <view class='success_diceng'>
98 <view class='success_one'> 98 <view class='success_one'>
99 <image src='/images/icon_55.png'></image> 99 <image src='/images/icon_55.png'></image>
100 </view> 100 </view>
101 <view class='success_font'>支付失败</view> 101 <view class='success_font'>支付失败</view>
102 - status为1的时候才能支付 102 + <!-- status为1的时候才能支付 -->
103 <view class='fail_font' wx:if="{{info.status == 0}}">不在活动时间,您不能支付</view> 103 <view class='fail_font' wx:if="{{info.status == 0}}">不在活动时间,您不能支付</view>
104 <view class='fail_font' wx:else>所需积分{{order.xy}},积分余额{{order.syjf}}</view> 104 <view class='fail_font' wx:else>所需积分{{order.xy}},积分余额{{order.syjf}}</view>
105 <navigator class='success_confirm_btn' open-type="navigateBack">取消支付</navigator> 105 <navigator class='success_confirm_btn' open-type="navigateBack">取消支付</navigator>
106 </view> 106 </view>
107 -</view> -->  
108 -<view class="peijianMask" wx-if="{{fail}}">  
109 - <view class="peijianPopup">  
110 - <view class="typePopop_quxiao" bindtap="payFail">  
111 - <image src="/images/quxiao11.png" mode="widthFix" style="width: 48rpx;"></image>  
112 - </view>  
113 - <view style="padding: 32rpx;margin-top: 80rpx;">  
114 - <view style="display: flex;flex-direction: column;align-items: center;">  
115 - <image src="/images/jinggao.png" mode="widthFix" style="width: 126rpx;"></image>  
116 - <text style="font-size: 32rpx; color: #000;margin: 16rpx 0;">支付失败</text>  
117 - <text style="font-size: 28rpx;">您的积分不足,可使用微信支付差价</text>  
118 - </view>  
119 - <view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">  
120 - <view style="font-size: 28rpx;">  
121 - 共需积分  
122 - </view>  
123 - <view style="font-size: 32rpx;color: #3D9BF5;">  
124 - {{order.xy}}  
125 - </view>  
126 - </view>  
127 - <view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">  
128 - <view style="font-size: 28rpx;">  
129 - 当前积分  
130 - </view>  
131 - <view style="font-size: 32rpx;color: #3D9BF5;">  
132 - {{order.syjf}}  
133 - </view>  
134 - </view>  
135 - <view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">  
136 - <view style="font-size: 28rpx;">  
137 - 差价支付  
138 - </view>  
139 - <view style="font-size: 32rpx;color: #ED261C;">  
140 - ¥{{payMent}}  
141 - </view>  
142 - </view>  
143 - <view style="margin-top: 114rpx;display: flex;align-items: center;font-size: 28rpx;justify-content: space-between;">  
144 - <view>  
145 - <text style="color: rgba(0,0,0,0.26);">共{{info.totalnum + choudanNum}}件,</text>  
146 - <text style="color: rgba(0,0,0,0.6);">合计:</text>  
147 - <text style="color: #3D9BF5;">{{order.xy}}积分,</text>  
148 - <text style="color: rgba(0,0,0,0.6);">差价:</text>  
149 - <text style="color: #ED261C;">¥{{payMent}}</text>  
150 - </view>  
151 - <view style="width: 222rpx;height: 88rpx;background-color: #3D9BF5;border-radius: 96rpx;display: flex;align-items: center;justify-content: center;font-size: 32rpx;color: #FFFFFF;" bindtap="mixedPay">  
152 - 提交  
153 - </view>  
154 - </view>  
155 - </view>  
156 - </view>  
157 </view> 107 </view>
158 <!-- 支付失败弹框结束 --> 108 <!-- 支付失败弹框结束 -->
159 109
160 <view class="cover_box" wx:if="{{cover_type}}"> 110 <view class="cover_box" wx:if="{{cover_type}}">
161 - <view class="cover_order">  
162 - <view class="all_money">{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</view>  
163 - <view class="money_item">  
164 - <text>商品积分</text>  
165 - <text>{{choudan_money?(choudan_money + info.total)/100:info.total/100}}积分</text>  
166 - </view>  
167 - <view class="money_item">  
168 - <text>邮费</text>  
169 - <text>{{info.yunfei/100}}积分</text>  
170 - </view>  
171 - <view class="cover_submit" catchtap="submit">确认支付</view>  
172 - <image src="/images/close.png" class="cover_close" catchtap="show_cover" /> 111 + <view class="cover_order">
  112 + <view class="all_money">{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</view>
  113 + <view class="money_item">
  114 + <text>商品积分</text>
  115 + <text>{{choudan_money?(choudan_money + info.total)/100:info.total/100}}积分</text>
173 </view> 116 </view>
  117 + <view class="money_item">
  118 + <text>邮费</text>
  119 + <text>{{info.yunfei/100}}积分</text>
  120 + </view>
  121 + <view class="cover_submit" catchtap="submit">确认支付</view>
  122 + <image src="/images/close.png" class="cover_close" catchtap="show_cover" />
  123 + </view>
174 </view> 124 </view>
@@ -18,7 +18,7 @@ Page({ @@ -18,7 +18,7 @@ Page({
18 }, 18 },
19 // 展示待支付的去支付弹窗 19 // 展示待支付的去支付弹窗
20 show_cover(e) { 20 show_cover(e) {
21 - if( app.globalData.status==0){ 21 + if( a.globalData.status==0){
22 wx.showToast({ 22 wx.showToast({
23 title: '您已您所在单位暂未开始劳保购买!', 23 title: '您已您所在单位暂未开始劳保购买!',
24 icon:'none' 24 icon:'none'
  1 +const app = getApp()
  2 +Page({
  3 +
  4 + /**
  5 + * 页面的初始数据
  6 + */
  7 + data: {
  8 + success: false,
  9 + fail: false,
  10 + name: '',
  11 + choudanNum: 0,
  12 + addressId: 0,
  13 + tel: '',
  14 + area: '',
  15 + address: '',
  16 + cover_type: false,
  17 + total: '',
  18 + payMent: '',
  19 + orderPayMent: '',
  20 +
  21 + info: {
  22 + address: {
  23 + address: '',
  24 + area: '',
  25 + id: '',
  26 + tel: '',
  27 + name: ''
  28 + }
  29 +
  30 + }
  31 + },
  32 + //加减商品数量
  33 + num_change(e) {
  34 + let that = this
  35 + let num = Number(e.currentTarget.dataset.num)
  36 + console.log(num)
  37 + let type = e.currentTarget.dataset.type
  38 + let index = e.currentTarget.dataset.index
  39 + let id = e.currentTarget.dataset.id
  40 + let check = e.currentTarget.dataset.check
  41 + let coudan = this.data.coudan || []
  42 + let coudan_arr = this.data.coudan_arr || []
  43 + let price = e.currentTarget.dataset.price;
  44 + let price2 = e.currentTarget.dataset.price2;
  45 +
  46 + if (type == 1) {
  47 + if (this.data.info.choudan * 100 < (price * 100)) {
  48 + wx.showToast({
  49 + title: '当前剩余积分不足,请重新挑选',
  50 + icon: 'none'
  51 + })
  52 + return
  53 + }
  54 + num++
  55 + } else {
  56 + num--
  57 + if (num < 0) {
  58 + num = 0;
  59 + return
  60 + }
  61 + }
  62 +
  63 + if (num < 1) {
  64 + coudan.forEach((item, index) => {
  65 + if (item.id == id) {
  66 + coudan.splice(index, 1)
  67 + coudan_arr.splice(index, 1)
  68 + }
  69 + })
  70 + } else {
  71 + if (type == 1 && num == 1) {
  72 + //选中
  73 + coudan.push({
  74 + id: id,
  75 + num: num
  76 + })
  77 + coudan_arr.push({
  78 + id: id,
  79 + num: num,
  80 + price: Number(price),
  81 + price2: Number(price2)
  82 + })
  83 + } else {
  84 + coudan.forEach((item, index) => {
  85 + if (item.id == id) {
  86 + item.num = num
  87 + coudan_arr[index].num = num
  88 + }
  89 + })
  90 + }
  91 +
  92 + }
  93 + that.setData({
  94 + coudan: coudan,
  95 + coudan_arr: coudan_arr,
  96 + [`info.coudanProduct[${index}].num`]: num
  97 + // [`info.coudanProduct[${index}].check`]: check
  98 + })
  99 + this.get_choudan()
  100 + },
  101 + // 计算凑单费用
  102 + get_choudan() {
  103 + let coudan_arr = this.data.coudan_arr
  104 + let choudan_money = 0;
  105 + let num = 0
  106 + for (let obj of coudan_arr) {
  107 + console.log(obj)
  108 + console.log(obj.price2)
  109 + if (obj.price2 != null) {
  110 + console.log(111)
  111 + choudan_money = (obj.price2 * 100 * obj.num) / 100 + choudan_money
  112 + } else {
  113 + console.log(222)
  114 + choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money
  115 + }
  116 + num = num + obj.num
  117 + }
  118 +
  119 + this.setData({
  120 + choudan_money: choudan_money * 100,
  121 + choudanNum: num,
  122 + 'info.choudan': this.data.info.syjf - choudan_money
  123 + // choudan_money: Math.floor(choudan_money* 100) / 100
  124 + })
  125 + },
  126 + show_cover() {
  127 + let that = this
  128 + if (!that.data.cover_type) {
  129 + if (that.data.info.status == 0) {
  130 + that.setData({
  131 + fail: true
  132 + })
  133 + return
  134 + }
  135 + if (!that.data.info.address) {
  136 + wx.showToast({
  137 + title: '请添加地址',
  138 + icon: 'none',
  139 + duration: 1000
  140 + })
  141 + return
  142 + }
  143 + }
  144 + that.setData({
  145 + cover_type: !this.data.cover_type
  146 + })
  147 + },
  148 + // 去添加地址
  149 + add_address() {
  150 + wx.navigateTo({
  151 + url: '/pages/address/address',
  152 + })
  153 + },
  154 +
  155 +
  156 + //选择凑单商品
  157 + chooseGoods(e) {
  158 + // coudan 凑单商品组成的数组
  159 + // coudan_type 凑单的状态 可能废弃
  160 + let that = this
  161 + let coudan = this.data.coudan ? this.data.coudan : []
  162 + let coudan_arr = this.data.coudan_arr ? this.data.coudan_arr : []
  163 + let check = e.currentTarget.dataset.check
  164 + let num = e.currentTarget.dataset.num
  165 + let index = e.currentTarget.dataset.index
  166 + let id = e.currentTarget.dataset.id
  167 + let price = e.currentTarget.dataset.price;
  168 + let price2 = e.currentTarget.dataset.price2;
  169 + if (check) {
  170 + check = 0
  171 + coudan.forEach((item, index) => {
  172 + if (item.id == id) {
  173 + coudan.splice(index, 1)
  174 + coudan_arr.splice(index, 1)
  175 + }
  176 + })
  177 + } else {
  178 + check = 1
  179 + //选中
  180 + coudan.push({
  181 + id: id,
  182 + num: num
  183 + })
  184 + coudan_arr.push({
  185 + id: id,
  186 + num: num,
  187 + price: Number(price),
  188 + price2: Number(price2)
  189 + })
  190 + }
  191 + that.setData({
  192 + coudan: coudan,
  193 + coudan_arr: coudan_arr,
  194 + [`info.coudanProduct[${index}].check`]: check
  195 + })
  196 + that.get_choudan()
  197 + },
  198 +
  199 + //获取页面信息
  200 + get_info(type, info, id) {
  201 + let that = this
  202 + let url = type == 4 ? app.interface.prev_pay : app.interface.now_prev_pay
  203 + let params = {
  204 + info: info
  205 + }
  206 + app.post(url, params).then((res) => {
  207 + console.log('99999', res, Number(res.msg.total))
  208 + res.msg.syjf = res.msg.choudan - res.msg.yunfei
  209 + let a = (res.msg.choudan - res.msg.yunfei).toFixed(2)
  210 + if (a < 0) {
  211 + a = 0
  212 + }
  213 + res.msg.choudan = a
  214 + res.msg.total = Number(res.msg.total * 100)
  215 + res.msg.yunfei = Number(res.msg.yunfei * 100)
  216 +
  217 + let total = (res.msg.total + res.msg.yunfei).toFixed("1");
  218 + console.log(total)
  219 +
  220 + that.setData({
  221 + info: res.msg,
  222 + total: total
  223 + })
  224 + console.log('9988756', that.data.info)
  225 +
  226 + })
  227 + },
  228 +
  229 +
  230 + //获取页面信息
  231 + get_youfei(id) {
  232 + let that = this
  233 + let url = that.data.type == 4 ? app.interface.youfei1 : app.interface.youfei
  234 + let params = {
  235 + info: that.data.params,
  236 + address_id: id
  237 + }
  238 + app.post(url, params).then((res) => {
  239 + that.setData({
  240 + "info.yunfei": Number(res.msg.yunfei) * 100
  241 + })
  242 + })
  243 + },
  244 + // 支付失败弹窗关闭
  245 + payFail() {
  246 + this.setData({
  247 + fail: false
  248 + })
  249 + },
  250 + // 混合支付
  251 + mixedPay() {
  252 + let that = this
  253 + let url = app.interface.orderMixed
  254 + let params = {
  255 + order_odd: that.data.orderPayMent,
  256 + money: that.data.payMent
  257 + }
  258 + app.post(url, params).then((res) => {
  259 + wx.requestPayment({
  260 + timeStamp: res.data.timestamp,
  261 + nonceStr: res.data.nonceStr,
  262 + package: res.data.package,
  263 + signType: 'MD5',
  264 + paySign: res.data.paySign,
  265 + success(res) {
  266 + console.log(res,'支付成功')
  267 + that.setData({
  268 + fail: false
  269 + })
  270 + wx.showToast({
  271 + title: '支付成功',
  272 + })
  273 + },
  274 + fail(res) {
  275 + console.log(res,'支付失败')
  276 + }
  277 + })
  278 + })
  279 + },
  280 + //点击支付
  281 + submit() {
  282 + let that = this
  283 + let list = that.data.info.products
  284 + let coudan = that.data.coudan
  285 + let info = []
  286 + if (that.data.type == 4) {
  287 + for (let obj of list) {
  288 + info.push({
  289 + id: obj.product.id,
  290 + num: obj.product.num
  291 + })
  292 + }
  293 + } else {
  294 + for (let obj of list) {
  295 + info.push({
  296 + id: obj.id,
  297 + num: obj.num
  298 + })
  299 + }
  300 + }
  301 + if (coudan && coudan.length > 0) {
  302 + info = info.concat(coudan)
  303 + }
  304 + let url = app.interface.now_add
  305 + let params = {
  306 + address: that.data.info.address.id,
  307 + info: JSON.stringify(info)
  308 + }
  309 + app.post(url, params).then((res) => {
  310 + that.setData({
  311 + cover_type: false
  312 + })
  313 + that.setData({
  314 + orderPayMent: res.msg
  315 + })
  316 + that.order_pay(res.msg)
  317 + })
  318 + },
  319 +
  320 + //订单支付
  321 + order_pay(order_odd) {
  322 + let that = this
  323 + let url = app.interface.order_pay
  324 + let params = {
  325 + order_odd: order_odd
  326 + }
  327 + app.post(url, params).then((res) => {
  328 + this.setData({
  329 + order: res.msg
  330 + })
  331 + if (res.msg.message == "支付成功") {
  332 + // wx.showToast({
  333 + // title: '购买成功',
  334 + // icon:'none'
  335 + // })
  336 + this.setData({
  337 + success: true
  338 + })
  339 + } else if (res.msg.message == "余额不足") {
  340 + this.setData({
  341 + fail: true
  342 + })
  343 + let payMents = (that.data.info.total + that.data.info.yunfei) / 100 - that.data.order.syjf
  344 + that.setData({
  345 + payMent: payMents.toFixed(2)
  346 + })
  347 + console.log(payMents, 'payMent')
  348 + }
  349 + })
  350 + },
  351 + /**
  352 + * 生命周期函数--监听页面加载
  353 + */
  354 + onLoad: function (options) {
  355 + console.log(options)
  356 + this.setData({
  357 + type: options.type,
  358 + params: options.info
  359 + })
  360 + this.get_info(options.type, options.info, options.id)
  361 + },
  362 +
  363 +
  364 + /**
  365 + * 生命周期函数--监听页面初次渲染完成
  366 + */
  367 + onReady: function () {
  368 +
  369 + },
  370 +
  371 + /**
  372 + * 生命周期函数--监听页面显示
  373 + */
  374 + onShow: function () {
  375 +
  376 + let pages = getCurrentPages();
  377 +
  378 + let currPage = pages[pages.length - 1]
  379 + console.log('887766554', currPage.data.id)
  380 + if (currPage.data.id) {
  381 + console.log('4778785', this.data.info)
  382 +
  383 + this.setData({
  384 + "info.address.address": currPage.data.address,
  385 + "info.address.area": currPage.data.area,
  386 + "info.address.id": currPage.data.id,
  387 + "info.address.tel": currPage.data.tel,
  388 + "info.address.name": currPage.data.name
  389 + })
  390 + console.log(this.data.info)
  391 + console.log(currPage.data.address)
  392 + this.get_youfei(currPage.data.id)
  393 + }
  394 + // if (wx.getStorageSync('no_address')) {
  395 + // wx.setStorageSync('no_address', false)
  396 + // this.setData({
  397 + // "info.address": null
  398 + // })
  399 + // }
  400 +
  401 + },
  402 +
  403 + /**
  404 + * 生命周期函数--监听页面隐藏
  405 + */
  406 + onHide: function () {
  407 +
  408 + },
  409 +
  410 + /**
  411 + * 生命周期函数--监听页面卸载
  412 + */
  413 + onUnload: function () {
  414 +
  415 + },
  416 +
  417 + /**
  418 + * 页面相关事件处理函数--监听用户下拉动作
  419 + */
  420 + onPullDownRefresh: function () {
  421 +
  422 + },
  423 +
  424 + /**
  425 + * 页面上拉触底事件的处理函数
  426 + */
  427 + onReachBottom: function () {
  428 +
  429 + },
  430 +
  431 + /**
  432 + * 用户点击右上角分享
  433 + */
  434 + onShareAppMessage: function () {
  435 +
  436 + }
  437 +})
  1 +<view class="content">
  2 + <!-- 地址信息 -->
  3 + <view class="address_box" wx:if="{{info.address}}" bindtap="add_address">
  4 + <view class="name">{{info.address.name}}
  5 + <text>{{info.address.tel}}</text>
  6 + <text>{{info.address.b_tel||""}}</text>
  7 + </view>
  8 + <view class="address">
  9 + <image class="tips_img" src="/images/icon_54.png" />
  10 + <view>{{info.address.area}}{{info.address.address}}</view>
  11 + </view>
  12 + <image src="/images/icon_41.png" class="youjiantou" />
  13 + </view>
  14 +
  15 + <view class="on_address" wx:else bindtap="add_address">
  16 + <image src="/images/icon_46.png" />
  17 + <view>暂无收货地址,
  18 + <text>去添加</text>
  19 + </view>
  20 + </view>
  21 + <view class="line">
  22 + <image src="/images/line.png" />
  23 + </view>
  24 +
  25 + <view class="content">
  26 + <shop_item list="{{info.products}}" type="{{type}}" />
  27 + <view class='recommend' wx:if="{{info.coudanProduct.length>0}}">
  28 + <view class='re_one'>*您支付后还剩{{info.choudan}}积分为您推荐了以下凑单产品!</view>
  29 + <scroll-view class='re_goods' scroll-x scroll-left="0">
  30 + <view class='re_item' wx:for='{{info.coudanProduct}}' wx:key='index' data-index="{{index}}" data-id="{{item.id}}" data-num="{{item.num?item.num:1}}" data-check='{{item.check}}' data-price='{{item.price}}' data-price2="{{item.price2}}">
  31 + <view class='re_re_item {{item.check?"active":""}}'>
  32 + <view class='triangle' wx:if='{{item.check}}'>
  33 + <image src='/images/bingo.png' class='bingo'></image>
  34 + </view>
  35 + <view class='re_re_img'>
  36 + <image src='{{item.images[0]}}' mode='aspectFill'></image>
  37 + </view>
  38 + <view class='re_bottom'>
  39 + <view class='re_re_name'>{{item.name}}</view>
  40 + <view class='re_re_score' wx:if="{{item.price!=null}}">{{item.price2}}积分</view>
  41 + <view class='re_re_score' wx:else>{{item.price}}积分</view>
  42 + </view>
  43 +
  44 + <!-- 数量操作 -->
  45 + <view class="num_box">
  46 + <image class="num_btn" src="/images/reduce.png" data-check='{{item.check}}' wx:if="{{item.num}}" data-index="{{index}}" data-id="{{item.id}}" data-type="0" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
  47 + <text wx:if="{{item.num}}">{{item.num?item.num:0}}</text>
  48 + <image class="num_btn" src="/images/add.png" data-check='{{item.check}}' data-index="{{index}}" data-id="{{item.id}}" data-type="1" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
  49 + </view>
  50 + </view>
  51 + </view>
  52 + </scroll-view>
  53 + </view>
  54 +
  55 + <view class='three'>
  56 + <view class='mask_two'>
  57 + <view>订单编号</view>
  58 + <view class='score'>{{info.order_odd}}</view>
  59 + </view>
  60 +
  61 + <view class='mask_two'>
  62 + <view>创建时间</view>
  63 + <view class='score'>{{info.date}}</view>
  64 + </view>
  65 +
  66 + <view class='mask_two'>
  67 + <view>邮费</view>
  68 + <view class='score' style="color:rgba(242, 0, 0, 1)">{{info.yunfei/100}}积分</view>
  69 + </view>
  70 + </view>
  71 + </view>
  72 +</view>
  73 +
  74 +<view class="footer">
  75 + <view class="submit" catchtap="show_cover">提交</view>
  76 + <view class="jifen"> 合计:
  77 + <!-- <text>{{choudan_money?choudan_money + info.total + info.yunfei*100/100: info.total + info.yunfei*100/100}}积分</text> -->
  78 + <text>{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</text>
  79 + </view>
  80 + <view class="num">共{{info.totalnum + choudanNum}}件</view>
  81 +</view>
  82 +<concat />
  83 +
  84 +<!-- 支付成功弹框开始 -->
  85 +<view class='success_mask' wx:if='{{success}}'>
  86 + <view class='success_diceng'>
  87 + <view class='success_one'>
  88 + <image src='/images/success.png'></image>
  89 + </view>
  90 + <view class='success_font'>支付成功</view>
  91 + <navigator class='success_confirm_btn' open-type="navigateBack">确定</navigator>
  92 + </view>
  93 +</view>
  94 +<!-- 支付成功弹框结束 -->
  95 +<!-- 支付失败弹框开始 -->
  96 +<!-- <view class='success_mask' wx:if='{{fail}}'>
  97 + <view class='success_diceng'>
  98 + <view class='success_one'>
  99 + <image src='/images/icon_55.png'></image>
  100 + </view>
  101 + <view class='success_font'>支付失败</view>
  102 + status为1的时候才能支付
  103 + <view class='fail_font' wx:if="{{info.status == 0}}">不在活动时间,您不能支付</view>
  104 + <view class='fail_font' wx:else>所需积分{{order.xy}},积分余额{{order.syjf}}</view>
  105 + <navigator class='success_confirm_btn' open-type="navigateBack">取消支付</navigator>
  106 + </view>
  107 +</view> -->
  108 +<view class="peijianMask" wx-if="{{fail}}">
  109 + <view class="peijianPopup">
  110 + <view class="typePopop_quxiao" bindtap="payFail">
  111 + <image src="/images/quxiao11.png" mode="widthFix" style="width: 48rpx;"></image>
  112 + </view>
  113 + <view style="padding: 32rpx;margin-top: 80rpx;">
  114 + <view style="display: flex;flex-direction: column;align-items: center;">
  115 + <image src="/images/jinggao.png" mode="widthFix" style="width: 126rpx;"></image>
  116 + <text style="font-size: 32rpx; color: #000;margin: 16rpx 0;">支付失败</text>
  117 + <text style="font-size: 28rpx;">您的积分不足,可使用微信支付差价</text>
  118 + </view>
  119 + <view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
  120 + <view style="font-size: 28rpx;">
  121 + 共需积分
  122 + </view>
  123 + <view style="font-size: 32rpx;color: #3D9BF5;">
  124 + {{order.xy}}
  125 + </view>
  126 + </view>
  127 + <view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
  128 + <view style="font-size: 28rpx;">
  129 + 当前积分
  130 + </view>
  131 + <view style="font-size: 32rpx;color: #3D9BF5;">
  132 + {{order.syjf}}
  133 + </view>
  134 + </view>
  135 + <view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
  136 + <view style="font-size: 28rpx;">
  137 + 差价支付
  138 + </view>
  139 + <view style="font-size: 32rpx;color: #ED261C;">
  140 + ¥{{payMent}}
  141 + </view>
  142 + </view>
  143 + <view style="margin-top: 114rpx;display: flex;align-items: center;font-size: 28rpx;justify-content: space-between;">
  144 + <view>
  145 + <text style="color: rgba(0,0,0,0.26);">共{{info.totalnum + choudanNum}}件,</text>
  146 + <text style="color: rgba(0,0,0,0.6);">合计:</text>
  147 + <text style="color: #3D9BF5;">{{order.xy}}积分,</text>
  148 + <text style="color: rgba(0,0,0,0.6);">差价:</text>
  149 + <text style="color: #ED261C;">¥{{payMent}}</text>
  150 + </view>
  151 + <view style="width: 222rpx;height: 88rpx;background-color: #3D9BF5;border-radius: 96rpx;display: flex;align-items: center;justify-content: center;font-size: 32rpx;color: #FFFFFF;" bindtap="mixedPay">
  152 + 提交
  153 + </view>
  154 + </view>
  155 + </view>
  156 + </view>
  157 +</view>
  158 +<!-- 支付失败弹框结束 -->
  159 +
  160 +<view class="cover_box" wx:if="{{cover_type}}">
  161 + <view class="cover_order">
  162 + <view class="all_money">{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</view>
  163 + <view class="money_item">
  164 + <text>商品积分</text>
  165 + <text>{{choudan_money?(choudan_money + info.total)/100:info.total/100}}积分</text>
  166 + </view>
  167 + <view class="money_item">
  168 + <text>邮费</text>
  169 + <text>{{info.yunfei/100}}积分</text>
  170 + </view>
  171 + <view class="cover_submit" catchtap="submit">确认支付</view>
  172 + <image src="/images/close.png" class="cover_close" catchtap="show_cover" />
  173 + </view>
  174 +</view>
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 </view> 11 </view>
12 <view class="btn_box"> 12 <view class="btn_box">
13 <view class="check" data-id="{{item.id}}" data-index="{{index}}" wx:if="{{item.mo != 1}}" catchtap="mrAddressFun"> 13 <view class="check" data-id="{{item.id}}" data-index="{{index}}" wx:if="{{item.mo != 1}}" catchtap="mrAddressFun">
14 - <image wx:if="{{item.is_default==2}}" src="/images/check.png" /> 14 + <image wx:if="{{!item.check}}" src="/images/check.png" />
15 <image wx:else src="/images/check@.png" /> 设为默认地址 15 <image wx:else src="/images/check@.png" /> 设为默认地址
16 </view> 16 </view>
17 <block> 17 <block>
@@ -321,7 +321,7 @@ Page({ @@ -321,7 +321,7 @@ Page({
321 321
322 onLoad: function (options) { 322 onLoad: function (options) {
323 console.log(app.globalData.index) 323 console.log(app.globalData.index)
324 - wx.setStorageSync('entrance_type', 0) 324 +
325 if (app.globalData.index == undefined) { 325 if (app.globalData.index == undefined) {
326 let that = this; 326 let that = this;
327 let token = wx.getStorageSync('token'); 327 let token = wx.getStorageSync('token');
@@ -1111,7 +1111,7 @@ Page({ @@ -1111,7 +1111,7 @@ Page({
1111 * 生命周期函数--监听页面显示 1111 * 生命周期函数--监听页面显示
1112 */ 1112 */
1113 onShow: function () { 1113 onShow: function () {
1114 - 1114 + wx.setStorageSync('entrance_type', 0)
1115 this.setData({ 1115 this.setData({
1116 logok: app.globalData.baseUrlimg + "assets/img/cb2ad36a391388f19f5f912fa021f8f.png" 1116 logok: app.globalData.baseUrlimg + "assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
1117 }) 1117 })