作者 lihongjuan

1

1 { 1 {
2 "pages": [ 2 "pages": [
3 "pages/homepage/homepage", 3 "pages/homepage/homepage",
  4 + "pages/goodtail/goodtail",
  5 +
4 "pages/login/login", 6 "pages/login/login",
5 "pages/cart/cart", 7 "pages/cart/cart",
6 "pages/orderbox/orderbox", 8 "pages/orderbox/orderbox",
@@ -9,7 +11,7 @@ @@ -9,7 +11,7 @@
9 "pages/dizhibox/dizhibox", 11 "pages/dizhibox/dizhibox",
10 "pages/message/message", 12 "pages/message/message",
11 "pages/mine/mine", 13 "pages/mine/mine",
12 - "pages/goodtail/goodtail", 14 +
13 "pages/orderdetail/orderdetail", 15 "pages/orderdetail/orderdetail",
14 "pages/sureorder/sureorder", 16 "pages/sureorder/sureorder",
15 "pages/searchbox/searchbox", 17 "pages/searchbox/searchbox",
@@ -55,6 +55,9 @@ @@ -55,6 +55,9 @@
55 </view> 55 </view>
56 <view class="goodname">{{item.goods_name}}</view> 56 <view class="goodname">{{item.goods_name}}</view>
57 </view> 57 </view>
  58 + <view class="attr" wx:for="{{goods_standard}}" wx:key=''>
  59 + <view class="goodbottomright attritem">{{item}}</view>
  60 + </view>
58 </view> 61 </view>
59 <view class="songk"> 62 <view class="songk">
60 <image src="/img/send.png"></image> 63 <image src="/img/send.png"></image>
@@ -69,6 +72,9 @@ @@ -69,6 +72,9 @@
69 </view> 72 </view>
70 <view class="goodname">{{item.gift.goods_name}}</view> 73 <view class="goodname">{{item.gift.goods_name}}</view>
71 </view> 74 </view>
  75 + <view class="attr" wx:for="{{goods_standard}}" wx:key=''>
  76 + <view class="goodbottomright attritem">{{item}}</view>
  77 + </view>
72 </view> 78 </view>
73 </view> 79 </view>
74 80
@@ -120,4 +126,6 @@ @@ -120,4 +126,6 @@
120 </view> 126 </view>
121 127
122 <view class="cartbottomright" bindtap="jiesuan">结算</view> 128 <view class="cartbottomright" bindtap="jiesuan">结算</view>
123 -</view>  
  129 +</view>
  130 +
  131 +
@@ -262,4 +262,8 @@ page { @@ -262,4 +262,8 @@ page {
262 color:#FF5A4E; 262 color:#FF5A4E;
263 font-size: 30rpx; 263 font-size: 30rpx;
264 font-weight: bold; 264 font-weight: bold;
  265 +}
  266 +image{
  267 + width:100%;
  268 + height:100%;
265 } 269 }
@@ -25,10 +25,11 @@ Page({ @@ -25,10 +25,11 @@ Page({
25 totalping: 0, 25 totalping: 0,
26 giftstandard: '请选择规格', 26 giftstandard: '请选择规格',
27 standard: '请选择规格', 27 standard: '请选择规格',
28 - standardarr:[],  
29 - giftstandardarr:[],  
30 - buynum:1  
31 - 28 + standardarr: [],
  29 + giftstandardarr: [],
  30 + buynum: 1,
  31 + buytype: '', //1 加入购物车 2立即购买
  32 + attrshow: false
32 }, 33 },
33 34
34 /** 35 /**
@@ -71,7 +72,7 @@ Page({ @@ -71,7 +72,7 @@ Page({
71 72
72 }) 73 })
73 }, 74 },
74 - 75 + // 获取商品详情
75 getgoodtail() { 76 getgoodtail() {
76 let that = this; 77 let that = this;
77 var url = 'goods/get_one'; 78 var url = 'goods/get_one';
@@ -94,7 +95,7 @@ Page({ @@ -94,7 +95,7 @@ Page({
94 95
95 that.data.goodtail.gift.standard.forEach(function(value, index, array) { 96 that.data.goodtail.gift.standard.forEach(function(value, index, array) {
96 value.selindex = -1, 97 value.selindex = -1,
97 - value.selname = '' 98 + value.selname = ''
98 }) 99 })
99 that.setData({ 100 that.setData({
100 goodtail: that.data.goodtail 101 goodtail: that.data.goodtail
@@ -104,33 +105,38 @@ Page({ @@ -104,33 +105,38 @@ Page({
104 105
105 }) 106 })
106 }, 107 },
107 - reducenum(){  
108 - this.data.buynum=this.data.buynum-1;  
109 - if(this.data.buynum==1){ 108 + reducenum() {
  109 + this.data.buynum = this.data.buynum - 1;
  110 + if (this.data.buynum == 1) {
110 this.setData({ 111 this.setData({
111 - buynum:this.data.buynum 112 + buynum: this.data.buynum
112 }) 113 })
113 } 114 }
114 }, 115 },
115 - addnum(){  
116 - this.data.buynum = this.data.buynum +1; 116 + addnum() {
  117 + this.data.buynum = this.data.buynum + 1;
117 this.setData({ 118 this.setData({
118 buynum: this.data.buynum 119 buynum: this.data.buynum
119 }) 120 })
120 }, 121 },
121 122
  123 + uniq(array) {
  124 +
  125 + return temp;
  126 + },
  127 + // 选择属性
122 selattr(e) { 128 selattr(e) {
123 let that = this; 129 let that = this;
124 console.log(e) 130 console.log(e)
125 let index = e.currentTarget.dataset.index; 131 let index = e.currentTarget.dataset.index;
126 let attrindex = e.currentTarget.dataset.bindex; 132 let attrindex = e.currentTarget.dataset.bindex;
127 - let name=e.currentTarget.dataset.name 133 + let name = e.currentTarget.dataset.name
128 console.log(index); 134 console.log(index);
129 console.log(attrindex) 135 console.log(attrindex)
130 that.data.standardarr.push(name) 136 that.data.standardarr.push(name)
131 that.data.goodtail.standard[attrindex].selindex = index; 137 that.data.goodtail.standard[attrindex].selindex = index;
132 that.data.goodtail.standard[attrindex].selname = name; 138 that.data.goodtail.standard[attrindex].selname = name;
133 - 139 +
134 that.setData({ 140 that.setData({
135 goodtail: that.data.goodtail, 141 goodtail: that.data.goodtail,
136 standardarr: that.data.standardarr 142 standardarr: that.data.standardarr
@@ -138,7 +144,7 @@ Page({ @@ -138,7 +144,7 @@ Page({
138 console.log(that.data.goodtail) 144 console.log(that.data.goodtail)
139 console.log(that.data.standardarr) 145 console.log(that.data.standardarr)
140 }, 146 },
141 - selgiftattr(e){ 147 + selgiftattr(e) {
142 let that = this; 148 let that = this;
143 console.log(e) 149 console.log(e)
144 let index = e.currentTarget.dataset.index; 150 let index = e.currentTarget.dataset.index;
@@ -159,13 +165,22 @@ Page({ @@ -159,13 +165,22 @@ Page({
159 }, 165 },
160 //加入购物车 166 //加入购物车
161 addcart() { 167 addcart() {
162 - let that = this; 168 + this.setData({
  169 + buytype: 1,
  170 + attrshow: true
  171 + })
  172 +
  173 + },
  174 +
  175 + addcartk() {
  176 + let that = this
163 var url = 'car/update_car'; 177 var url = 'car/update_car';
164 var params = { 178 var params = {
165 goods_id: that.data.goodid, 179 goods_id: that.data.goodid,
166 type: 1, 180 type: 1,
167 - goods_standard:that.data.standardarr.join(","),  
168 - give_standard: that.data.giftstandardarr.join(",") 181 + goods_standard: that.data.standardarr.join(","),
  182 + give_standard: that.data.giftstandardarr.join(","),
  183 + number: that.data.buynum
169 184
170 } 185 }
171 app.post(url, params).then((res) => { 186 app.post(url, params).then((res) => {
@@ -174,6 +189,12 @@ Page({ @@ -174,6 +189,12 @@ Page({
174 title: '添加购物车成功', 189 title: '添加购物车成功',
175 icon: 'none' 190 icon: 'none'
176 }) 191 })
  192 +
  193 + setTimeout(function(){
  194 + that.setData({
  195 + attrshow:false
  196 + })
  197 + },1500)
177 that.getqipao() 198 that.getqipao()
178 199
179 200
@@ -246,13 +267,22 @@ Page({ @@ -246,13 +267,22 @@ Page({
246 267
247 //立即抢购 268 //立即抢购
248 lijiqiang() { 269 lijiqiang() {
  270 + this.setData({
  271 + buytype: 2,
  272 + attrshow: true
  273 + })
  274 + },
  275 +
  276 + lijiqiangk() {
249 let that = this; 277 let that = this;
250 var url = 'order/confirm_order'; 278 var url = 'order/confirm_order';
251 var params = { 279 var params = {
252 goods_ids: that.data.goodtail.id, 280 goods_ids: that.data.goodtail.id,
253 take_id: '', 281 take_id: '',
254 - type: 1  
255 - 282 + type: 1,
  283 + goods_standard: that.data.standardarr.join(","),
  284 + give_standard: that.data.giftstandardarr.join(","),
  285 + number: that.data.buynum
256 } 286 }
257 app.post(url, params).then((res) => { 287 app.post(url, params).then((res) => {
258 console.log(res); 288 console.log(res);
@@ -266,15 +296,16 @@ Page({ @@ -266,15 +296,16 @@ Page({
266 let freight = res.freight; 296 let freight = res.freight;
267 let price = res.price; 297 let price = res.price;
268 let total = res.total; 298 let total = res.total;
  299 + let give_standard = res.give_standard
  300 + let goods_standard = res.goods_standard
  301 + console.log(give_standard);
  302 + console.log(goods_standard)
  303 + app.globalData.give_standard = give_standard;
269 304
270 -  
271 - console.log(freight);  
272 - console.log(price);  
273 - console.log(total);  
274 - console.log(orderarr); 305 + app.globalData.goods_standard = goods_standard;
275 306
276 wx.navigateTo({ 307 wx.navigateTo({
277 - url: '/pages/sureorder/sureorder?orderarr=' + neworderarr + '&freight=' + freight + '&price=' + price + '&total=' + total + '&type=' + 1, 308 + url: '/pages/sureorder/sureorder?orderarr=' + neworderarr + '&freight=' + freight + '&price=' + price + '&total=' + total + '&type=' + 1
278 }) 309 })
279 310
280 311
@@ -285,6 +316,83 @@ Page({ @@ -285,6 +316,83 @@ Page({
285 }) 316 })
286 }) 317 })
287 }, 318 },
  319 + //确定购买或加入购物车
  320 + surebuy() {
  321 + let that = this;
  322 + console.log(that.data.goodtail)
  323 + var arr = [];
  324 + var giftarr = [];
  325 + that.data.goodtail.standard.forEach(function(value, index, array) {
  326 +
  327 + console.log(value);
  328 + console.log(value.selname)
  329 + if (value.selname != "") {
  330 + arr.push(value.selname);
  331 +
  332 + }
  333 +
  334 + })
  335 +
  336 + var temp = []; //一个新的临时数组 去掉多选的商品属性
  337 + for (var i = 0; i < arr.length; i++) {
  338 + if (temp.indexOf(arr[i]) == -1) {
  339 + temp.push(arr[i]);
  340 + }
  341 + }
  342 +
  343 +
  344 + that.data.goodtail.gift.standard.forEach(function(value, index, array) {
  345 +
  346 + console.log(value);
  347 + console.log(value.selname)
  348 + if (value.selname != "") {
  349 + giftarr.push(value.selname);
  350 +
  351 + }
  352 +
  353 + })
  354 +
  355 + var gifttemp = []; //一个新的临时数组 去掉多选的商品属性
  356 + for (var i = 0; i < giftarr.length; i++) {
  357 + if (gifttemp.indexOf(giftarr[i]) == -1) {
  358 + gifttemp.push(giftarr[i]);
  359 + }
  360 + }
  361 +
  362 + that.setData({
  363 + standardarr: temp,
  364 + giftstandardarr: gifttemp
  365 + })
  366 +
  367 +
  368 + if (that.data.standardarr.length != that.data.goodtail.standard.length) {
  369 +
  370 +
  371 + wx.showToast({
  372 + title: '请选择商品属性',
  373 + icon: 'none'
  374 + })
  375 +
  376 + } else if (that.data.giftstandardarr.length != that.data.goodtail.gift.standard.length) {
  377 +
  378 + wx.showToast({
  379 + title: '请选择赠品属性',
  380 + icon: 'none'
  381 + })
  382 +
  383 + } else {
  384 + if (that.data.buytype == 1) {
  385 + that.addcartk()
  386 + } else {
  387 + that.lijiqiangk()
  388 + }
  389 + }
  390 +
  391 +
  392 +
  393 +
  394 + },
  395 +
288 /** 396 /**
289 * 生命周期函数--监听页面初次渲染完成 397 * 生命周期函数--监听页面初次渲染完成
290 */ 398 */
@@ -149,7 +149,7 @@ @@ -149,7 +149,7 @@
149 </view> 149 </view>
150 150
151 <!-- 选择商品属性 --> 151 <!-- 选择商品属性 -->
152 -<view class="registerk"> 152 +<view class="registerk" wx:if="{{attrshow}}">
153 <view class="naturewrap"> 153 <view class="naturewrap">
154 <view class="naturebox"> 154 <view class="naturebox">
155 <view class="naturetop flexone"> 155 <view class="naturetop flexone">
@@ -212,8 +212,8 @@ @@ -212,8 +212,8 @@
212 </view> 212 </view>
213 213
214 214
215 - <view class="cartbottom boxcartbot">  
216 - <view class="cartbottomleft" bindtap="gocart"> 215 + <view class="cartbottom boxcartbot surebot">
  216 + <!-- <view class="cartbottomleft" bindtap="gocart">
217 <view class="cartbototmtopimg"> 217 <view class="cartbototmtopimg">
218 <image src="/img/shop.png"></image> 218 <image src="/img/shop.png"></image>
219 <view class="cartnum">{{count}}</view> 219 <view class="cartnum">{{count}}</view>
@@ -222,11 +222,12 @@ @@ -222,11 +222,12 @@
222 <view class="gouwucart">购物车</view> 222 <view class="gouwucart">购物车</view>
223 223
224 224
225 - </view> 225 + </view> -->
226 226
227 <view class="cartright"> 227 <view class="cartright">
228 - <view class="cartleftname" bindtap="addcart">加入购物车</view>  
229 - <view class="qianggou" bindtap="lijiqiang">立即抢购</view> 228 + <!-- <view class="cartleftname" bindtap="addcart">加入购物车</view> -->
  229 + <!-- <view class="qianggou" bindtap="surebuy">确定</view> -->
  230 + <view class="surebuy" bindtap="surebuy">确定</view>
230 </view> 231 </view>
231 </view> 232 </view>
232 233
@@ -349,6 +349,23 @@ @@ -349,6 +349,23 @@
349 line-height: 77rpx; 349 line-height: 77rpx;
350 border-radius: 4rpx 20rpx 20rpx 4rpx; 350 border-radius: 4rpx 20rpx 20rpx 4rpx;
351 } 351 }
  352 +.surebot{
  353 + display:flex;
  354 + justify-content: center;
  355 + align-items: center
  356 +}
  357 +.surebuy{
  358 + width:500rpx;
  359 + height:77rpx;
  360 + background: rgba(255, 90, 78, 1);
  361 + color:#fff;
  362 + font-size: 28rpx;
  363 + text-align: center;
  364 + line-height: 77rpx;
  365 + border-radius: 44rpx;
  366 + margin:0 auto;
  367 +
  368 +}
352 369
353 .cartright { 370 .cartright {
354 display: flex; 371 display: flex;
@@ -15,7 +15,9 @@ Page({ @@ -15,7 +15,9 @@ Page({
15 type:'', 15 type:'',
16 goodsid:[], 16 goodsid:[],
17 remark:'', 17 remark:'',
18 - order_id:'' 18 + order_id:'',
  19 + goods_standard:[],
  20 + give_standard:[]
19 }, 21 },
20 22
21 /** 23 /**
@@ -33,8 +35,13 @@ Page({ @@ -33,8 +35,13 @@ Page({
33 orderarr: JSON.parse(options.orderarr), 35 orderarr: JSON.parse(options.orderarr),
34 freight: options.freight, 36 freight: options.freight,
35 type:options.type, 37 type:options.type,
  38 + give_standard: app.globalData.give_standard,
  39 + goods_standard: app.globalData.goods_standard
36 }) 40 })
37 41
  42 + console.log(this.data.give_standard)
  43 + console.log(this.data.goods_standard)
  44 +
38 let neworderarr=this.data.orderarr; 45 let neworderarr=this.data.orderarr;
39 let newgoodsid=this.data.goodsid; 46 let newgoodsid=this.data.goodsid;
40 for(var obj of neworderarr){ 47 for(var obj of neworderarr){
@@ -28,18 +28,21 @@ @@ -28,18 +28,21 @@
28 <image src="{{item.image}}"></image> 28 <image src="{{item.image}}"></image>
29 </view> 29 </view>
30 30
31 - <view class="xiename"> 31 + <view class="xiek">
32 <view class="xienameleft"> 32 <view class="xienameleft">
33 <image src="/img/good.png"></image> 33 <image src="/img/good.png"></image>
34 </view> 34 </view>
35 <view class="goodname">{{item.goods_name}}</view> 35 <view class="goodname">{{item.goods_name}}</view>
36 - <view class="goodname">x{{item.number}}</view> 36 + <view class="goodname">x{{item.number}}</view>
37 </view> 37 </view>
38 38
39 <view class="goodbottom"> 39 <view class="goodbottom">
40 <view class="goodbottomleft">¥{{item.price}}</view> 40 <view class="goodbottomleft">¥{{item.price}}</view>
41 <view class="goodbottomright" wx:if="{{item.freight==0.00}}">运费:免运费</view> 41 <view class="goodbottomright" wx:if="{{item.freight==0.00}}">运费:免运费</view>
42 - <view class="goodbottomright" wx:else>运费:{{item.freight}}元</view> 42 + <view class="goodbottomright" wx:else>运费:{{item.freight}}元</view>
  43 + </view>
  44 + <view class="attr" wx:for="{{goods_standard}}" wx:key=''>
  45 + <view class="goodbottomright attritem">{{item}}</view>
43 </view> 46 </view>
44 </view> 47 </view>
45 48
@@ -64,6 +67,9 @@ @@ -64,6 +67,9 @@
64 <view class="goodbottomright" wx:if='{{item.gift.freight==0.00}}'>运费:免运费</view> 67 <view class="goodbottomright" wx:if='{{item.gift.freight==0.00}}'>运费:免运费</view>
65 <view class="goodbottomright" wx:else>运费:{{item.gift.freight}}元</view> 68 <view class="goodbottomright" wx:else>运费:{{item.gift.freight}}元</view>
66 </view> 69 </view>
  70 + <view class="attr" wx:for="{{give_standard}}" wx:key=''>
  71 + <view class="goodbottomright attritem">{{item}}</view>
  72 + </view>
67 </view> 73 </view>
68 </view> 74 </view>
69 75
@@ -82,7 +88,7 @@ @@ -82,7 +88,7 @@
82 </view> 88 </view>
83 89
84 <view class="beizhuenter"> 90 <view class="beizhuenter">
85 - <input placeholder='请填写订单备注' placeholder-class='entermark' bindinput="entertext"/> 91 + <input placeholder='请填写订单备注' placeholder-class='entermark' bindinput="entertext" />
86 </view> 92 </view>
87 </view> 93 </view>
88 94
@@ -122,3 +122,19 @@ @@ -122,3 +122,19 @@
122 line-height: 88rpx; 122 line-height: 88rpx;
123 margin-top:80rpx; 123 margin-top:80rpx;
124 } 124 }
  125 +.attr{
  126 + display:flex;
  127 +
  128 + align-items: center;
  129 + margin-top:10rpx;
  130 + flex-wrap: wrap;
  131 +}
  132 +.attritem{
  133 + margin-right:8rpx
  134 +}
  135 +.xiek{
  136 + display: flex;
  137 +
  138 +margin-top: 24rpx;
  139 +
  140 +}
@@ -4,13 +4,23 @@ @@ -4,13 +4,23 @@
4 "ignore": [] 4 "ignore": []
5 }, 5 },
6 "setting": { 6 "setting": {
7 - "urlCheck": true, 7 + "urlCheck": false,
8 "es6": true, 8 "es6": true,
9 "postcss": true, 9 "postcss": true,
10 "minified": true, 10 "minified": true,
11 "newFeature": true, 11 "newFeature": true,
  12 + "coverView": true,
12 "autoAudits": false, 13 "autoAudits": false,
13 - "checkInvalidKey": true 14 + "showShadowRootInWxmlPanel": true,
  15 + "scopeDataCheck": false,
  16 + "checkInvalidKey": true,
  17 + "checkSiteMap": true,
  18 + "uploadWithSourceMap": true,
  19 + "babelSetting": {
  20 + "ignore": [],
  21 + "disablePlugins": [],
  22 + "outputPath": ""
  23 + }
14 }, 24 },
15 "compileType": "miniprogram", 25 "compileType": "miniprogram",
16 "libVersion": "2.9.2", 26 "libVersion": "2.9.2",