Commit 5638d36da298bf13eb70e769b365d10c9cfca4fc

Authored by 范牧
Exists in master

解决冲突

src/components/CommodityCard/CommodityCard.vue
1 1 <template>
2 2 <view
3 3 class="card"
4   - @tap="toGoods(goods.id?goods.id:goods.pid)"
  4 + @tap="toGoods(goods.id?goods.id:goods.pid,goods.sk_id)"
5 5 >
6 6 <image
7 7 mode="widthFix"
... ... @@ -10,9 +10,9 @@
10 10 <view class="name">{{goods.name?goods.name:goods.p_name}}</view>
11 11 <view class="info">
12 12 <view class="priceBox">
13   - <view class="price">{{goods.oldPrice !== undefined?goods.oldPrice:goods.old_price}}</view>
  13 + <view class="price">{{goods.oldPrice !== undefined?goods.oldPrice:goods.real_price}}</view>
14 14 <view class="originCost">
15   - {{goods.price !== undefined?goods.price:goods.real_price}}
  15 + {{goods.price !== undefined?goods.price:goods.old_price}}
16 16 </view>
17 17 </view>
18 18 <view class="trade_num">{{goods.trade_num}}人购买</view>
... ... @@ -46,10 +46,10 @@ export default {
46 46 }
47 47 },
48 48 methods: {
49   - toGoods (id) {
50   - console.log('---', '../frameDetail/frameDetail?pid=' + id)
  49 + toGoods (id,sk_id) {
  50 + console.log('---', '../frameDetail/frameDetail?pid=' + id+'&sk_id='+sk_id)
51 51 uni.navigateTo({
52   - url: '../frameDetail/frameDetail?pid=' + id,
  52 + url: '../frameDetail/frameDetail?pid=' + id+'&sk_id='+sk_id,
53 53 success: res => {},
54 54 fail: () => {},
55 55 complete: () => {}
... ...
src/pages/cart/cart.vue
... ... @@ -28,11 +28,11 @@
28 28 <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image>
29 29 </view> -->
30 30 <view class="infoRight">
31   - <view class="goodName" @tap="toGoods(item.pid)">{{item.p_name}}</view>
  31 + <view class="goodName" @tap="toGoods(item.pid,item.sk_id)">{{item.p_name}}</view>
32 32 <!-- <view class="describ"> -->
33 33 <uni-collapse accordion="true" >
34 34 <uni-collapse-item showAnimation='true'
35   - :title="item.tag.prod_tag_fun[0].label+'/'+item.tag.prod_tag_fun[1].label+'/'+item.tag.prod_tag_fun[2].label+'...'" >
  35 + :title="item.tag.prod_tag_fun[0].label+'/'+item.tag.prod_tag_fun[1].label+'/'+item.tag.prod_tag_fun[2].label+'...' || '暂无'" >
36 36 <text class="describ">
37 37 <block v-for="tag in item.tag.prod_tag_fun" :key="tag.value">
38 38 {{tag.label+`&nbsp;&nbsp;`}}
... ... @@ -93,7 +93,7 @@ export default {
93 93 computed: {
94 94  
95 95 cartList() {
96   - console.log('cart-list', this.$store.state.cart.cartList);
  96 + // console.log('cart-list', this.$store.state.cart.cartList);
97 97 return this.$store.state.cart.cartList
98 98 },
99 99 childIsOpen() {
... ... @@ -124,10 +124,11 @@ export default {
124 124  
125 125 methods: {
126 126  
127   - toGoods(id) {
128   - console.log('---', '../frameDetail/frameDetail?pid=' + id)
  127 + toGoods(id, sk_id) {
  128 + console.log('cart-list', this.$store.state.cart.cartList);
  129 + console.log('---', '../frameDetail/frameDetail?pid=' + id +'&sk_id='+sk_id)
129 130 uni.navigateTo({
130   - url: '../frameDetail/frameDetail?pid=' + id,
  131 + url: '../frameDetail/frameDetail?pid=' + id+'&sk_id='+sk_id,
131 132 success: res => {},
132 133 fail: () => {},
133 134 complete: () => {}
... ...
src/pages/frameDetail/frameDetail.vue
... ... @@ -302,7 +302,6 @@
302 302 </block> -->
303 303 </view>
304 304 </view>
305   -
306 305 <!-- 底部菜单 -->
307 306 <view class="botton">
308 307 <view
... ... @@ -336,7 +335,8 @@ export default {
336 335 pid: 0,
337 336 // 购物车数据
338 337 addCartList: {
339   - mp_id: 335,
  338 + mp_id: 0,
  339 + uid: 0,
340 340 sk_id: 0,
341 341 num: 1,
342 342 price: ''
... ... @@ -382,10 +382,12 @@ export default {
382 382 }
383 383 }
384 384 },
385   - onLoad: function ({ pid }) {
  385 + onLoad: function ({ pid,sk_id }) {
386 386 this.pid = pid
  387 + // console.log('sk_id=====>',sk_id)
387 388 store.dispatch('read/fetch', {
388   - pid
  389 + pid,
  390 + sk_id
389 391 }).then(() => {
390 392 this.parameter[0].slength = `${this.goodInfo.frame_width}mm`
391 393 this.parameter[1].slength = `${this.goodInfo.glass_width}mm`
... ... @@ -394,10 +396,15 @@ export default {
394 396 this.parameter[4].slength = `${this.goodInfo.leg_long}mm`
395 397 this.parameter[5].slength = `${this.goodInfo.weight}mm`
396 398 this.tag = this.goodInfo.tag
397   - this.addCartList.price = this.goodInfo.p_sale_price
398 399 this.test = this.goodInfo.prodIntro1
399 400 this.test = this.test.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
  401 + // addCart
  402 + this.addCartList.price = this.goodInfo.p_sale_price
  403 + this.addCartList.sk_id = this.goodInfo.skuList[0].sk_id
  404 + this.addCartList.mp_id = this.goodInfo.glassData.mp_id
  405 + this.addCartList.uid = this.$store.state.user.userInfo.uid
400 406 })
  407 + // console.log(this.$store.state.user.userInfo.uid + 'ssss')
401 408 },
402 409 computed: {
403 410 updateGoodType () {
... ... @@ -427,8 +434,7 @@ export default {
427 434 sk_id: this.addCartList.sk_id,
428 435 num: this.addCartList.num,
429 436 pid: this.pid,
430   - price: this.addCartList.price,
431   - checkedSKU: {}
  437 + price: this.addCartList.price
432 438 })
433 439 store.dispatch('cart/getCartList', {
434 440 uid: this.$store.state.user.userInfo.uid // 用户id
... ... @@ -473,18 +479,6 @@ export default {
473 479 // break
474 480 // }
475 481 },
476   - // 加入购物车
477   - addCart () {
478   - store.dispatch('cart/addCart', {
479   - uid: this.$store.state.user.userInfo.uid,
480   - openid: this.$store.state.user.userInfo.openid,
481   - pid: this.pid,
482   - checkedSKU: {}
483   - })
484   - store.dispatch('cart/getCartList', {
485   - uid: this.$store.state.user.userInfo.uid // 用户id
486   - })
487   - },
488 482 tabChange (e) {
489 483 if (this.current !== e) {
490 484 this.current = e
... ...
src/pages/index/index.vue
... ... @@ -126,6 +126,7 @@ export default {
126 126 computed: {
127 127 goodsList () {
128 128 // 也可以从 getters 获取
  129 + // console.log('index-list=====>',this.$store.state.index.list)
129 130 return this.$store.state.index.list
130 131 },
131 132 categoryList () {
... ...
src/store/modules/read.js
... ... @@ -17,11 +17,27 @@ const mutations = {
17 17  
18 18 const actions = {
19 19 fetch({ commit }, param) {
  20 + // 由于购物车和用户推荐的价格要根据sk_id来获取
  21 + const arg=Object.assign({},param)
  22 + delete param.sk_id
20 23 return new Promise((resolve, reject) => request({
21 24 url: read,
22 25 data: param,
23 26 success: (res) => {
24   - commit('INIT', res.data.data)
  27 + console.log('readParm====>',arg)
  28 + console.log('read====>',res.data.data)
  29 + // 用一个新的对象来接收sk_id找的值
  30 + const Res=Object.assign({},res.data.data)
  31 + if(arg.sk_id!=undefined){
  32 + for (let i = 0; i < res.data.data.skuList.length; i++) {
  33 + if(res.data.data.skuList[i].sk_id==arg.sk_id){
  34 + Res.p_sale_price= res.data.data.skuList[i].real_price
  35 + console.log('陈工了')
  36 + }
  37 + }
  38 + }
  39 + console.log(Res)
  40 + commit('INIT', Res)
25 41 resolve()
26 42 },
27 43 fail: (res) => {
... ...