diff --git a/.eslintrc.js b/.eslintrc.js index f962912..e0b044f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -26,6 +26,14 @@ module.exports = { ], "rules": { quotes: ['error', 'single'], - 'space-before-function-paren': 0 + 'space-before-function-paren': 0, + // 数组和对象键值对最后一个逗号, never参数:不能带末尾的逗号, always参数:必须带末尾的逗号, + // always-multiline:多行模式必须带逗号,单行模式不能带逗号 + "comma-dangle": [2, "always-multiline"], + // 控制逗号前后的空格 + "comma-spacing": [2, { "before": false, "after": true }], + // 控制逗号在行尾出现还是在行首出现 + // http://eslint.org/docs/rules/comma-style + "comma-style": [2, "last"], } }; diff --git a/src/components/CommodityCard/CommodityCard.vue b/src/components/CommodityCard/CommodityCard.vue index 38494b9..f98ab9b 100644 --- a/src/components/CommodityCard/CommodityCard.vue +++ b/src/components/CommodityCard/CommodityCard.vue @@ -10,9 +10,10 @@ {{goods.name?goods.name:goods.p_name}} - {{goods.oldPrice !== undefined?goods.oldPrice:goods.old_price}} + {{goods.old_price ? goods.old_price : (goods.rsSon && goods.rsSon.Min_Price)}} - {{goods.price !== undefined?goods.price:goods.real_price}} + + {{goods.real_price ? goods.real_price : parseInt(goods.rsSon && goods.rsSon.Min_Price*(1 + Number(goods.rsSon.discount)/100))}} {{goods.trade_num}}人购买 @@ -34,8 +35,8 @@ export default { originCost: String, price: String, trade_num: String, - goodType: String - } + goodType: String, + }, }, created () { @@ -52,10 +53,10 @@ export default { url: '../frameDetail/frameDetail?pid=' + id, success: res => {}, fail: () => {}, - complete: () => {} + complete: () => {}, }) - } - } + }, + }, } diff --git a/src/pages/confirmOrder/confirmOrder.vue b/src/pages/confirmOrder/confirmOrder.vue index 0a630b1..876940c 100644 --- a/src/pages/confirmOrder/confirmOrder.vue +++ b/src/pages/confirmOrder/confirmOrder.vue @@ -61,7 +61,9 @@ 商品名称商品名称商品名称名称名称 支持7天无理由退货 顺丰发货 - ¥198 + ¥{{Number(skuInfo.real_price) * count}} + ¥{{parseInt(skuInfo.real_price * (1 + Number(skuInfo.discount) / 100))}} + - 规格 玫瑰金/钛合金 + 规格 + + {{attrList[index].attr[item].name}}/ + 配送方式 快递 买家留言 合计 - ¥{{total}} + ¥{{Number(skuInfo.real_price) * count}} @@ -150,7 +158,7 @@ --> - 实付金额:¥{{total}} + 实付金额:¥{{Number(skuInfo.real_price) * count}} { if (code === 1) { console.log('code', code, data) @@ -204,14 +211,23 @@ export default { }) } store.dispatch('read/fetch', { - pid + pid, }) }, computed: { goodInfo () { - console.log(this.$store.state.read.goodInfo) + console.log('state', this.$store.state) return this.$store.state.read.goodInfo - } + }, + skuInfo () { + return this.$store.state.order.param.sk_id_arr + }, + attrList () { + return this.$store.state.order.param.attrList + }, + current () { + return this.$store.state.order.param.current + }, }, methods: { counter(isadd) { @@ -221,40 +237,57 @@ export default { this.count <= 1 ? this.disabled = true : this.count-- } }, + // 跳转添加地址页面 toaddAddress() { uni.navigateTo({ url: `../address/addressList?edit=${1}`, success: res => {}, fail: (error) => { console.log('跳转到地址列表页面失败====>', error) }, - complete: () => {} + complete: () => {}, }) }, // 下单 orderBuild() { console.log('this', this.$store.state) - // store.dispatch('order/build', { - // pid: 2, - // sk_id: '23', - // number: 2, - // mp_id: '201', - // totalPrice: 101, - // address: this.addressInfo, - // dir: 1 - // }) - } + const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param + store.dispatch('order/buyNow', { + pid: skId.pid, + sk_id: skId.sk_id, + number: this.count, + mp_id: mpId, + address: JSON.stringify(this.addressInfo), + totalPrice: Number(this.skuInfo.real_price) * this.count * 100, + liuyan: this.note, + dir: 1, + }).then((res) => { + this.pay(res.data) + }) + }, // 支付 - // pay() { - // const openId = uni.getStorageSync('openid') - // const fieldSet = { - // 'openid': this.$store.state.user.userInfo.openid, - // 'uid': this.$store.state.user.userInfo.uid, - // 'shopid': 0, - // 'payCate': 2020, - // 'payMoney': , - // '' - // } - // } - } + pay(res) { + console.log('pay', res) + const { data, exKeyName: keyName } = res + const uid = uni.getStorageSync('uid') + const fieldSet = { + openid: this.$store.state.user.userInfo.openid, + uid: this.$store.state.user.userInfo.uid, + shopid: 0, + payCate: 2020, + payMoney: Number(this.skuInfo.real_price) * this.count * 100, + payWoodId: `fcdj-${uid}-${keyName}`, + nonceStr: 'asfafasfasfasfasf', + signType: 'MD5', + app_uid: 2020, + timeStamp: new Date().getTime().toString(), + billInfo: JSON.stringify(data), + keyname: keyName, + } + console.log('fieldSet', fieldSet) + store.dispatch('order/pay', fieldSet).then((res) => { + console.log('res', res) + }) + }, + }, } @@ -355,6 +388,11 @@ export default { color: #ff6b4a; font-size: 28rpx; } + .originCost { + text-decoration: line-through; + color: #999999; + font-size: 20rpx; + } .counter { display: flex; flex-direction: row; diff --git a/src/pages/frameDetail/frameDetail.vue b/src/pages/frameDetail/frameDetail.vue index 806393a..569297d 100644 --- a/src/pages/frameDetail/frameDetail.vue +++ b/src/pages/frameDetail/frameDetail.vue @@ -19,7 +19,7 @@ > - ¥{{goodInfo.p_sale_price || '暂无'}}{{goodInfo.trade_num || '暂无'}}人购买过 + ¥{{goodInfo.priceArea.Min_Price || '暂无'}}{{goodInfo.trade_num || '暂无'}}人购买过 {{goodInfo.p_name || '暂无'}} 支持7天无理由退货顺丰发货30天质量保证 @@ -31,7 +31,7 @@ 风格:{{introduction.func}} 适用性别:{{introduction.rate}} - @@ -46,7 +46,7 @@ 材质:{{introduction.material}} 直径/基弧:{{introduction.func}} 适用性别:{{introduction.rate}} - + --> { this.parameter[0].slength = `${this.goodInfo.frame_width}mm` this.parameter[1].slength = `${this.goodInfo.glass_width}mm` @@ -406,7 +406,7 @@ export default { goodInfo () { console.log(this.$store.state.read.goodInfo) return this.$store.state.read.goodInfo - } + }, }, methods: { // 前往购物车 @@ -415,7 +415,7 @@ export default { url: '/pages/cart/cart', success: res => {}, fail: (error) => { console.log('跳转购物车失败======>', error) }, - complete: () => { console.log('toCart') } + complete: () => { console.log('toCart') }, }) }, // 加入购物车 @@ -428,10 +428,10 @@ export default { num: this.addCartList.num, pid: this.pid, price: this.addCartList.price, - checkedSKU: {} + checkedSKU: {}, }) store.dispatch('cart/getCartList', { - uid: this.$store.state.user.userInfo.uid // 用户id + uid: this.$store.state.user.userInfo.uid, // 用户id }) }, goPerchase () { @@ -442,7 +442,7 @@ export default { url: `../purchaseLenses/purchaseLenses?pid=${this.pid}`, success: res => {}, fail: (error) => { console.log('跳转参数选择失败======>', error) }, - complete: () => { console.log('goPerchase') } + complete: () => { console.log('goPerchase') }, }) // break // case '2': @@ -479,18 +479,18 @@ export default { uid: this.$store.state.user.userInfo.uid, openid: this.$store.state.user.userInfo.openid, pid: this.pid, - checkedSKU: {} + checkedSKU: {}, }) store.dispatch('cart/getCartList', { - uid: this.$store.state.user.userInfo.uid // 用户id + uid: this.$store.state.user.userInfo.uid, // 用户id }) }, tabChange (e) { if (this.current !== e) { this.current = e } - } - } + }, + }, }