Commit b9fb65756bd1f5c23acec70473f8d84a74494c4c

Authored by 喻鹏
1 parent b83c44fe1f
Exists in master

购物车和推荐产品根据sk_id来对应价格

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
... ... @@ -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`
... ...
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) => {
... ...