From 089dce19da0a1073daa2d196144ffda8ef050f50 Mon Sep 17 00:00:00 2001 From: mullins <476823686@qq.com> Date: Wed, 27 May 2020 16:44:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 10 +- src/components/CommodityCard/CommodityCard.vue | 15 +- src/pages/confirmOrder/confirmOrder.vue | 108 ++- src/pages/frameDetail/frameDetail.vue | 44 +- src/pages/myOrder/myOrder.vue | 15 +- src/pages/purchaseLenses/purchaseLenses.vue | 1238 ++++++++++++------------ src/store/modules/myLoveList.js | 21 +- src/store/modules/order.js | 48 +- src/store/request.js | 10 +- src/store/url.js | 6 +- 10 files changed, 793 insertions(+), 722 deletions(-) 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 @@ <view class="name">{{goods.name?goods.name:goods.p_name}}</view> <view class="info"> <view class="priceBox"> - <view class="price">{{goods.oldPrice !== undefined?goods.oldPrice:goods.old_price}}</view> + <view class="price">{{goods.old_price ? goods.old_price : (goods.rsSon && goods.rsSon.Min_Price)}}</view> <view class="originCost"> - {{goods.price !== undefined?goods.price:goods.real_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))}} </view> </view> <view class="trade_num">{{goods.trade_num}}人购买</view> @@ -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: () => {}, }) - } - } + }, + }, } </script> 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 @@ <text class="goodName">商品名称商品名称商品名称名称名称</text> <text class="remarks">支持7天无理由退货 顺丰发货</text> <view class="priceBox"> - <view class="price">¥198</view> + <view class="price">¥{{Number(skuInfo.real_price) * count}}<text class="originCost"> + ¥{{parseInt(skuInfo.real_price * (1 + Number(skuInfo.discount) / 100))}} + </text></view> <view class="counter"> <view class="btn" @@ -80,7 +82,13 @@ </view> </view> <view class="infoBottom"> - <view class="norm">规格 <text>玫瑰金/钛合金</text></view> + <view class="norm">规格 <text > + <!-- 长度超出变省略号未做 --> + <block + v-for="(item, index) in current" + :key="index" + >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block></block> + </text></view> <view class="shippingMethod">配送方式 <text>快递</text></view> <view class="message">买家留言 <input @@ -136,7 +144,7 @@ <view class="item"> <text>合计</text> <view class="itemRight"> - <view class="total">¥{{total}}</view> + <view class="total">¥{{Number(skuInfo.real_price) * count}}</view> </view> </view> </view> @@ -150,7 +158,7 @@ </view> --> </view> <view class="footer"> - <view class="footerLeft">实付金额:<text>¥{{total}}</text></view> + <view class="footerLeft">实付金额:<text>¥{{Number(skuInfo.real_price) * count}}</text></view> <view class="footerRight"> <view class="paybtn" @@ -171,22 +179,21 @@ export default { count: 1, pid: 0, disabled: false, - total: 120, freight: 0.00, showAddress: false, note: '', addressInfo: { - address: '' - } + address: '', + }, // isAnonymous: } }, - onLoad({ pid, addressId }) { + onLoad({ pid, addressId, isCart }) { this.pid = pid // 若已经选择地址 if (addressId) { store.dispatch('address/details', { - add_id: addressId + add_id: addressId, }).then(({ code, data }) => { 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) + }) + }, + }, } </script> @@ -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 @@ ></image> </swiper-item> </swiper> - <view class="D1_price">¥{{goodInfo.p_sale_price || '暂无'}}<span class="D1_number">{{goodInfo.trade_num || '暂无'}}人购买过</span></view> + <view class="D1_price">¥{{goodInfo.priceArea.Min_Price || '暂无'}}<span class="D1_number">{{goodInfo.trade_num || '暂无'}}人购买过</span></view> <view class="D1_name"><span class="D1_name1">{{goodInfo.p_name || '暂无'}}</span></view> <view class="D1_spans"><span>支持7天无理由退货</span><span>顺丰发货</span><span>30天质量保证</span></view> </view> @@ -31,7 +31,7 @@ <view><span class="D2_span1">风格:</span><span class="D2_span2">{{introduction.func}}</span></view> <view><span class="D2_span1">适用性别:</span><span class="D2_span2">{{introduction.rate}}</span></view> </view> - <view + <!-- <view class="D2" v-if="updateGoodType == 1" > @@ -46,7 +46,7 @@ <view><span class="D2_span1">材质:</span><span class="D2_span2">{{introduction.material}}</span></view> <view><span class="D2_span1">直径/基弧:</span><span class="D2_span2">{{introduction.func}}</span></view> <view><span class="D2_span1">适用性别:</span><span class="D2_span2">{{introduction.rate}}</span></view> - </view> + </view> --> <view class="D3"> <view class="screenBar"> <view @@ -339,12 +339,12 @@ export default { mp_id: 335, sk_id: 0, num: 1, - price: '' + price: '', }, screenItems: [ { current: 0, text: '商品介绍' }, { current: 1, text: '规格参数' }, - { current: 2, text: '售后保障' } + { current: 2, text: '售后保障' }, ], current: 0, starCount: 5, @@ -354,38 +354,38 @@ export default { { key: 2, img: '/static/img/detail/d4.png', standard: '镜片高', slength: '45mm' }, { key: 3, img: '/static/img/detail/d5.png', standard: '鼻架宽', slength: '19mm' }, { key: 4, img: '/static/img/detail/d6.png', standard: '框架耳长', slength: '138mm' }, - { key: 5, img: '/static/img/detail/d7.png', standard: '框架重', slength: '19mm' } + { key: 5, img: '/static/img/detail/d7.png', standard: '框架重', slength: '19mm' }, ], esvalue: '宝贝好评率', introduction: { material: '钛合金', func: '抗疲劳/防辐射', - rate: '男/女' + rate: '男/女', }, imgAll: '/static/img/detail/d8.png', photoes: [ { value: '日常办公', img: '/static/img/detail/d9.png' }, { value: '上网', img: '/static/img/detail/d10.png' }, { value: '追剧', img: '/static/img/detail/d11.png' }, - { value: '玩游戏', img: '/static/img/detail/d12.png' } + { value: '玩游戏', img: '/static/img/detail/d12.png' }, ], imgDetail: '/static/img/detail/d13.png', imgShop: { img: '/static/tab-cart.png', - IsShown: false + IsShown: false, }, tag: { prod_tag_freesend: [{ label: '眼镜盒', - value: '262' - }] - } + value: '262', + }], + }, } }, onLoad: function ({ pid }) { this.pid = pid store.dispatch('read/fetch', { - pid + pid, }).then(() => { 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 } - } - } + }, + }, } </script> <style lang='scss'> diff --git a/src/pages/myOrder/myOrder.vue b/src/pages/myOrder/myOrder.vue index b012d7a..110cf91 100644 --- a/src/pages/myOrder/myOrder.vue +++ b/src/pages/myOrder/myOrder.vue @@ -39,7 +39,7 @@ import store from '@/store' export default { components: { - OrderCard: OrderCard + OrderCard: OrderCard, }, data() { return { @@ -48,20 +48,19 @@ export default { { current: '10', text: '全部' }, { current: '0', text: '待付款' }, { current: '1', text: '待收货' }, - { current: '2', text: '已完成' } + { current: '2', text: '已完成' }, // {current:"3",text:'已评价'}, // {current:"4",text:'退款'}, ], // 当前所在item 默认10-->全部 - current: '10' + current: '10', } }, onLoad: function(option) { // 获取订单列表 store.dispatch('myOrder/getList', { - uid: '1', - way: '' + way: '', }) // 从user过来传的status,给current,以显示对应item this.current = option.status @@ -70,7 +69,7 @@ export default { orderList() { // console.log('orderList', this.$store.state.myOrder.orderList); return this.$store.state.myOrder.orderList - } + }, }, methods: { // tab点击事件 @@ -78,9 +77,9 @@ export default { if (this.current !== e) { this.current = e } - } + }, - } + }, } </script> diff --git a/src/pages/purchaseLenses/purchaseLenses.vue b/src/pages/purchaseLenses/purchaseLenses.vue index 81dd6d5..a71be63 100644 --- a/src/pages/purchaseLenses/purchaseLenses.vue +++ b/src/pages/purchaseLenses/purchaseLenses.vue @@ -36,139 +36,139 @@ <view class="opCollapse"> <view class="body"> <template v-if="opIsOpen"> - <view class="goods-form"> - <view class="p1"> - <image class="image2" src="../../static/img/myOpticsData/dataWrite.png" mode="aspectFit"></image> - 填写验光数据 - </view> - <text class="p2">没有验光数据?请到线下眼镜店验光哦~</text> - <view class="picker"> - <view class="picker-choice"> - <view class="choice-left"> - <text class="pd">验光单取名:</text> - </view> - <input type="text" @blur="handleInput" class="input" - placeholder="请输入名称" maxlength="20" :value="name" /> - </view> - </view> - <view class="picker" > - <view class="picker-choice"> - <view class="choice-left"> - <text class="p11">{{pickerInfoList[0].nameC}}</text> - <text class="p12">{{pickerInfoList[0].nameE}}</text> - </view> - <text class="p13">左 (OD)</text> - <!-- <text class="p14">{{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}}</text> --> - <picker @change="bindPickerChange01" :value="pickerInfoList[0].nameIndex1" :range="pickerInfoList[0].nameArray1"> - <view class="p14"> - {{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - <!-- <image src="../../static/detail-tabicon.png" ></image> --> - </picker> - <text class="p13">右 (OS)</text> - <!-- <text class="p14">{{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}}</text> --> - <picker @change="bindPickerChange02" :value="pickerInfoList[0].nameIndex2" :range="pickerInfoList[0].nameArray2"> - <view class="p14"> - {{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - <!-- <image src="../../static/detail-tabicon.png" ></image> --> - </picker> - </view> - </view> - <view class="picker" > - <view class="picker-choice"> - <view class="choice-left"> - <text class="p11">{{pickerInfoList[1].nameC}}</text> - <text class="p12">{{pickerInfoList[1].nameE}}</text> - </view> - <text class="p13">左 (OD)</text> - <!-- <text class="p14">{{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}}</text> --> - <picker @change="bindPickerChange11" :value="pickerInfoList[1].nameIndex1" :range="pickerInfoList[1].nameArray1"> - <view class="p14"> - {{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - <!-- <image src="../../static/detail-tabicon.png" ></image> --> - </picker> - <text class="p13">右 (OS)</text> - <!-- <text class="p14">{{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}}</text> --> - <picker @change="bindPickerChange12" :value="pickerInfoList[1].nameIndex2" :range="pickerInfoList[1].nameArray2"> - <view class="p14"> - {{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - <!-- <image src="../../static/detail-tabicon.png" ></image> --> - </picker> - </view> - </view> - <view class="picker" > - <view class="picker-choice"> - <view class="choice-left"> - <text class="p11">{{pickerInfoList[2].nameC}}</text> - <text class="p12">{{pickerInfoList[2].nameE}}</text> - </view> - <text class="p13">左 (OD)</text> - <picker @change="bindPickerChange21" :value="pickerInfoList[2].nameIndex1" :range="pickerInfoList[2].nameArray1"> - <view class="p14"> - {{pickerInfoList[2].nameArray1[pickerInfoList[2].nameIndex1]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - </picker> - <text class="p13">右 (OS)</text> - <!-- <text class="p14">{{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}}</text> --> - <picker @change="bindPickerChange22" :value="pickerInfoList[2].nameIndex2" :range="pickerInfoList[2].nameArray2"> - <view class="p14"> - {{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - <!-- <image src="../../static/detail-tabicon.png" ></image> --> - </picker> - </view> - </view> - <view class="picker"> - <view class="picker-choice"> - <view class="choice-left"> - <text class="pd">瞳距:</text> - </view> - <input type="digit" @change="handleInputPd" class="input" - placeholder="请输入瞳距,单位cm" maxlength="20" :value="pd" /> - </view> - </view> - <view class="picker" > - <view class="picker-choice"> - <view class="choice-left"> - <text class="p11">{{pickerInfoList[3].nameC}}</text> - </view> - <text class="p13-date">年 (Y)</text> - <picker @change="bindPickerChange41" :value="pickerInfoList[3].nameIndex1" :range="pickerInfoList[3].nameArray1"> - <view class="p14" style="width: 30px;"> - {{pickerInfoList[3].nameArray1[pickerInfoList[3].nameIndex1]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - </picker> - <text class="p13-date">月 (M)</text> - <picker @change="bindPickerChange42" :value="pickerInfoList[3].nameIndex2" :range="pickerInfoList[3].nameArray2"> - <view class="p14" style="width: 30px;"> - {{pickerInfoList[3].nameArray2[pickerInfoList[3].nameIndex2]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - </picker> - <text class="p13-date">日 (D)</text> - <picker @change="bindPickerChange43" :value="pickerInfoList[3].nameIndex3" :range="pickerInfoList[3].nameArray3"> - <view class="p14" style="width: 30px;"> - {{pickerInfoList[3].nameArray3[pickerInfoList[3].nameIndex3]}} - <image src="../../static/detail-tabicon.png" ></image> - </view> - </picker> - </view> - </view> - <view class="confirm"> - <image class="image1" :src="confirm ? tabicon[0] : tabicon[1]" @tap="changeConfirm"></image> - <text>确认以上输入信息来源于我的验光数据!</text> - </view> - </view> + <view class="goods-form"> + <view class="p1"> + <image class="image2" src="../../static/img/myOpticsData/dataWrite.png" mode="aspectFit"></image> + 填写验光数据 + </view> + <text class="p2">没有验光数据?请到线下眼镜店验光哦~</text> + <view class="picker"> + <view class="picker-choice"> + <view class="choice-left"> + <text class="pd">验光单取名:</text> + </view> + <input type="text" @blur="handleInput" class="input" + placeholder="请输入名称" maxlength="20" :value="name" /> + </view> + </view> + <view class="picker" > + <view class="picker-choice"> + <view class="choice-left"> + <text class="p11">{{pickerInfoList[0].nameC}}</text> + <text class="p12">{{pickerInfoList[0].nameE}}</text> + </view> + <text class="p13">左 (OD)</text> + <!-- <text class="p14">{{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}}</text> --> + <picker @change="bindPickerChange01" :value="pickerInfoList[0].nameIndex1" :range="pickerInfoList[0].nameArray1"> + <view class="p14"> + {{pickerInfoList[0].nameArray1[pickerInfoList[0].nameIndex1]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + <!-- <image src="../../static/detail-tabicon.png" ></image> --> + </picker> + <text class="p13">右 (OS)</text> + <!-- <text class="p14">{{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}}</text> --> + <picker @change="bindPickerChange02" :value="pickerInfoList[0].nameIndex2" :range="pickerInfoList[0].nameArray2"> + <view class="p14"> + {{pickerInfoList[0].nameArray2[pickerInfoList[0].nameIndex2]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + <!-- <image src="../../static/detail-tabicon.png" ></image> --> + </picker> + </view> + </view> + <view class="picker" > + <view class="picker-choice"> + <view class="choice-left"> + <text class="p11">{{pickerInfoList[1].nameC}}</text> + <text class="p12">{{pickerInfoList[1].nameE}}</text> + </view> + <text class="p13">左 (OD)</text> + <!-- <text class="p14">{{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}}</text> --> + <picker @change="bindPickerChange11" :value="pickerInfoList[1].nameIndex1" :range="pickerInfoList[1].nameArray1"> + <view class="p14"> + {{pickerInfoList[1].nameArray1[pickerInfoList[1].nameIndex1]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + <!-- <image src="../../static/detail-tabicon.png" ></image> --> + </picker> + <text class="p13">右 (OS)</text> + <!-- <text class="p14">{{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}}</text> --> + <picker @change="bindPickerChange12" :value="pickerInfoList[1].nameIndex2" :range="pickerInfoList[1].nameArray2"> + <view class="p14"> + {{pickerInfoList[1].nameArray2[pickerInfoList[1].nameIndex2]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + <!-- <image src="../../static/detail-tabicon.png" ></image> --> + </picker> + </view> + </view> + <view class="picker" > + <view class="picker-choice"> + <view class="choice-left"> + <text class="p11">{{pickerInfoList[2].nameC}}</text> + <text class="p12">{{pickerInfoList[2].nameE}}</text> + </view> + <text class="p13">左 (OD)</text> + <picker @change="bindPickerChange21" :value="pickerInfoList[2].nameIndex1" :range="pickerInfoList[2].nameArray1"> + <view class="p14"> + {{pickerInfoList[2].nameArray1[pickerInfoList[2].nameIndex1]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + </picker> + <text class="p13">右 (OS)</text> + <!-- <text class="p14">{{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}}</text> --> + <picker @change="bindPickerChange22" :value="pickerInfoList[2].nameIndex2" :range="pickerInfoList[2].nameArray2"> + <view class="p14"> + {{pickerInfoList[2].nameArray2[pickerInfoList[2].nameIndex2]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + <!-- <image src="../../static/detail-tabicon.png" ></image> --> + </picker> + </view> + </view> + <view class="picker"> + <view class="picker-choice"> + <view class="choice-left"> + <text class="pd">瞳距:</text> + </view> + <input type="digit" @change="handleInputPd" class="input" + placeholder="请输入瞳距,单位cm" maxlength="20" :value="pd" /> + </view> + </view> + <view class="picker" > + <view class="picker-choice"> + <view class="choice-left"> + <text class="p11">{{pickerInfoList[3].nameC}}</text> + </view> + <text class="p13-date">年 (Y)</text> + <picker @change="bindPickerChange41" :value="pickerInfoList[3].nameIndex1" :range="pickerInfoList[3].nameArray1"> + <view class="p14" style="width: 30px;"> + {{pickerInfoList[3].nameArray1[pickerInfoList[3].nameIndex1]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + </picker> + <text class="p13-date">月 (M)</text> + <picker @change="bindPickerChange42" :value="pickerInfoList[3].nameIndex2" :range="pickerInfoList[3].nameArray2"> + <view class="p14" style="width: 30px;"> + {{pickerInfoList[3].nameArray2[pickerInfoList[3].nameIndex2]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + </picker> + <text class="p13-date">日 (D)</text> + <picker @change="bindPickerChange43" :value="pickerInfoList[3].nameIndex3" :range="pickerInfoList[3].nameArray3"> + <view class="p14" style="width: 30px;"> + {{pickerInfoList[3].nameArray3[pickerInfoList[3].nameIndex3]}} + <image src="../../static/detail-tabicon.png" ></image> + </view> + </picker> + </view> + </view> + <view class="confirm"> + <image class="image1" :src="confirm ? tabicon[0] : tabicon[1]" @tap="changeConfirm"></image> + <text>确认以上输入信息来源于我的验光数据!</text> + </view> + </view> </template> <template v-else> <view @@ -202,7 +202,7 @@ v-for="(item,index) in attrList" :key="index" > - <UniCollapse @change="change(index)"> + <UniCollapse @change="changeShow(index)"> <UniCollapseItem :open="show[index]" :title="item.meta_name" @@ -324,7 +324,7 @@ import store from '@/store' export default { components: { UniCollapse, - UniCollapseItem + UniCollapseItem, }, data() { return { @@ -344,11 +344,9 @@ export default { show: [], chooseRes1: { sku_name: 'Miss 黑二代【减龄自然】', - sk_id: '128' - }, - checkedData: { - + sk_id: '128', }, + checkedData: {}, chooseRes2: '14.0', chooseRes3: 0, chooseItem1: [ @@ -366,43 +364,43 @@ export default { { style: 'background-image: radial-gradient(50% 148%, #FFFFFF 50%, #324A05 100%);', describ: 'Miss 黑4代【防紫外线】' }, { style: 'background-image: radial-gradient(50% 143%, #AEA8A8 45%, #624B3F 100%);', describ: 'Miss 黑5代【防紫外线】' }, { style: 'opacity: 0.7;background-image: radial-gradient(50% 150%, #F0EEE7 50%, #6F0838 100%);', describ: 'Miss 黑6代【防紫外线】' }, - { style: 'background-image: radial-gradient(50% 143%, #AEA8A8 45%, #370B4E 100%);', describ: 'Miss 黑7代【防紫外线】' } + { style: 'background-image: radial-gradient(50% 143%, #AEA8A8 45%, #370B4E 100%);', describ: 'Miss 黑7代【防紫外线】' }, ], chooseItem2: [ { num: '14.0' }, { num: '14.2' }, { num: '14.4' }, - { num: '14.5' } + { num: '14.5' }, ], chooseItem3: [0, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 470, 500, 525, 550, 575, 600, 1000], // 度数相关数据 - pickerInfoList:[ - {nameC:"度数",nameE:"(SPH)",nameArray1:[''],nameIndex1:0,nameArray2:[''],nameIndex2:0,key:0}, - {nameC:"散光",nameE:"(CYL)",nameArray1:[''],nameIndex1:0,nameArray2:[''],nameIndex2:0,key:1}, - {nameC:"散光轴位",nameE:"(AXI)",nameArray1:[''],nameIndex1:0,nameArray2:[''],nameIndex2:0,key:2}, - {nameC:"验光日期",nameE:'',nameArray1:[''],nameIndex1:0,nameArray2:['',1,2,3,4,5,6,7,8,9,10,11,12],nameIndex2:0,nameArray3:[''],nameIndex3:0} - ], - confirm: false, // 用户是否确认 - tabicon:['/static/detail-button.png','/static/detail-button-unselected.png'], - name: '夏小花', - oldname:'',// 用于判读用户是否改变名字 - pickerInfoChioce:{ - "leftSph": '', - "rightSph": '', - "leftCyl": '', - "rightCyl": '', - "leftAxi": '', - "rightAxi": '', - "time":{ - "year":0, - "month": 0, - "day":0 , - } - }, - pd: '',// 瞳距 - oldpd: '',// 用于判断用户是否改变瞳距 - kinds:1, // kinds=1,提交为新增验光,2为修改 - mp_id: Number + pickerInfoList: [ + { nameC: '度数', nameE: '(SPH)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 0 }, + { nameC: '散光', nameE: '(CYL)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 1 }, + { nameC: '散光轴位', nameE: '(AXI)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 2 }, + { nameC: '验光日期', nameE: '', nameArray1: [''], nameIndex1: 0, nameArray2: ['', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], nameIndex2: 0, nameArray3: [''], nameIndex3: 0 }, + ], + confirm: false, // 用户是否确认 + tabicon: ['/static/detail-button.png', '/static/detail-button-unselected.png'], + name: '夏小花', + oldname: '', // 用于判读用户是否改变名字 + pickerInfoChioce: { + leftSph: '', + rightSph: '', + leftCyl: '', + rightCyl: '', + leftAxi: '', + rightAxi: '', + time: { + year: 0, + month: 0, + day: 0, + }, + }, + pd: '', // 瞳距 + oldpd: '', // 用于判断用户是否改变瞳距 + kinds: 1, // kinds=1,提交为新增验光,2为修改 + mp_id: Number, } }, computed: { @@ -414,12 +412,12 @@ export default { }, mpList() { return this.$store.state.myLoveList.loveList - } + }, }, onLoad({ pid }) { this.pid = pid store.dispatch('read/fetch', { - pid + pid, }).then(() => { const current = [] const show = [] @@ -431,149 +429,146 @@ export default { this.show = show }) store.dispatch('myLoveList/getLoveList') - - // 初始化SPL、CYL、AXI的值 - for (let j = 0; j < 3; j++) { - for(let i=-12;i<6;i++){ - this.pickerInfoList[j].nameArray1.push(i) - this.pickerInfoList[j].nameArray1.push(i+0.5) - this.pickerInfoList[j].nameArray2.push(i) - this.pickerInfoList[j].nameArray2.push(i+0.5) - if(i>=-6){ - this.pickerInfoList[j].nameArray1.push(i+0.25) - this.pickerInfoList[j].nameArray1.push(i+0.75) - this.pickerInfoList[j].nameArray2.push(i+0.25) - this.pickerInfoList[j].nameArray2.push(i+0.75) - } - if(i==5){ - this.pickerInfoList[j].nameArray1.push(i+1) - this.pickerInfoList[j].nameArray2.push(i+1) - } - } - } - // 初始化日期值 - for (let i = 1; i < 32; i++){ - this.pickerInfoList[3].nameArray3.push(i) - } - // 初始化年份前后五年 - let myDate = new Date(); - let nowYear = myDate.getFullYear(); - for(let i=0;i<5;i++){ - this.pickerInfoList[3].nameArray1.push(nowYear-i) - } + + // 初始化SPL、CYL、AXI的值 + for (let j = 0; j < 3; j++) { + for (let i = -12; i < 6; i++) { + this.pickerInfoList[j].nameArray1.push(i) + this.pickerInfoList[j].nameArray1.push(i + 0.5) + this.pickerInfoList[j].nameArray2.push(i) + this.pickerInfoList[j].nameArray2.push(i + 0.5) + if (i >= -6) { + this.pickerInfoList[j].nameArray1.push(i + 0.25) + this.pickerInfoList[j].nameArray1.push(i + 0.75) + this.pickerInfoList[j].nameArray2.push(i + 0.25) + this.pickerInfoList[j].nameArray2.push(i + 0.75) + } + if (i === 5) { + this.pickerInfoList[j].nameArray1.push(i + 1) + this.pickerInfoList[j].nameArray2.push(i + 1) + } + } + } + // 初始化日期值 + for (let i = 1; i < 32; i++) { + this.pickerInfoList[3].nameArray3.push(i) + } + // 初始化年份前后五年 + const myDate = new Date() + const nowYear = myDate.getFullYear() + for (let i = 0; i < 5; i++) { + this.pickerInfoList[3].nameArray1.push(nowYear - i) + } }, methods: { - // picker相关功能 - handleInput(e){ - this.name=e.target.value - this.isDataName = false - console.log('e---->', e) - const mpList = this.mpList - console.log('mpList===>',mpList) - for (let index = 0; index < mpList.length; index++) { - if (e.detail.value === mpList[index].name) { - this.isDataName = true - uni.showModal({ - title: '提示', - content: `是否填充已有的"${e.detail.value}"的数据`, - success: (res) => { - if (res.confirm) { - this.kinds=2 - console.log('args===>',index) - // const mpList=Object.assign({},this.$store.state.mympList.mpList) - console.log('mpList===>',mpList) - this.name=mpList[index].name - this.pd=mpList[index].pd - this.mp_id=mpList[index].mp_id - this.oldname=mpList[index].name - this.oldpd=mpList[index].pd - // 将kinds =2时的值传到该页面 - this.pickerInfoList[0].nameArray1.unshift(mpList[index].leftSph) - this.pickerInfoList[0].nameArray2.unshift(mpList[index].rightSph) - this.pickerInfoList[1].nameArray1.unshift(mpList[index].leftCyl) - this.pickerInfoList[1].nameArray2.unshift(mpList[index].rightCyl) - this.pickerInfoList[2].nameArray1.unshift(mpList[index].leftAxi) - this.pickerInfoList[2].nameArray2.unshift(mpList[index].rightAxi) - - this.pickerInfoList[3].nameArray1.unshift(mpList[index].in_time.toString().slice(0,4)) - if(mpList[index].in_time.toString().slice(5,6)==0){ - this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(6,7)) - } else{ - this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(5,7)) - } - if(mpList[index].in_time.toString().slice(8,9)==0){ - this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(9,10)) - } else{ - this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(8,10)) - } - // this.checkedData = mpList[index] - // console.log('checkedData', this.checkedData) - } else if(res.cancel){ - this.kinds=2 - } - } - }) - } - } - }, - handleInputPd(e){ - // 只能输入正浮点数或正数 - if(/^\d+(\.\d+)?$/.test(e.target.value)){ - this.pd=e.target.value - } else { - uni.showToast({ - title:"请输入有效数据;示例:89", - icon: "none", - duration: 2000, - }) - this.pd = '' - } - - }, + // picker相关功能 + handleInput(e) { + this.name = e.target.value + this.isDataName = false + console.log('e---->', e) + const mpList = this.mpList + console.log('mpList===>', mpList) + for (let index = 0; index < mpList.length; index++) { + if (e.detail.value === mpList[index].name) { + this.isDataName = true + uni.showModal({ + title: '提示', + content: `是否填充已有的"${e.detail.value}"的数据`, + success: (res) => { + if (res.confirm) { + this.kinds = 2 + console.log('args===>', index) + // const mpList=Object.assign({},this.$store.state.mympList.mpList) + console.log('mpList===>', mpList) + this.name = mpList[index].name + this.pd = mpList[index].pd + this.mp_id = mpList[index].mp_id + this.oldname = mpList[index].name + this.oldpd = mpList[index].pd + // 将kinds =2时的值传到该页面 + this.pickerInfoList[0].nameArray1.unshift(mpList[index].leftSph) + this.pickerInfoList[0].nameArray2.unshift(mpList[index].rightSph) + this.pickerInfoList[1].nameArray1.unshift(mpList[index].leftCyl) + this.pickerInfoList[1].nameArray2.unshift(mpList[index].rightCyl) + this.pickerInfoList[2].nameArray1.unshift(mpList[index].leftAxi) + this.pickerInfoList[2].nameArray2.unshift(mpList[index].rightAxi) + this.pickerInfoList[3].nameArray1.unshift(mpList[index].in_time.toString().slice(0, 4)) + if (mpList[index].in_time.toString().slice(5, 6) === 0) { + this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(6, 7)) + } else { + this.pickerInfoList[3].nameArray2.unshift(mpList[index].in_time.toString().slice(5, 7)) + } + if (mpList[index].in_time.toString().slice(8, 9) === 0) { + this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(9, 10)) + } else { + this.pickerInfoList[3].nameArray3.unshift(mpList[index].in_time.toString().slice(8, 10)) + } + // this.checkedData = mpList[index] + // console.log('checkedData', this.checkedData) + } else if (res.cancel) { + this.kinds = 2 + } + }, + }) + } + } + }, + handleInputPd(e) { + // 只能输入正浮点数或正数 + if (/^\d+(\.\d+)?$/.test(e.target.value)) { + this.pd = e.target.value + } else { + uni.showToast({ + title: '请输入有效数据;示例:89', + icon: 'none', + duration: 2000, + }) + this.pd = '' + } + }, changeConfirm() { - this.confirm = !this.confirm + this.confirm = !this.confirm + }, + bindPickerChange01: function(e) { + this.pickerInfoList[0].nameIndex1 = e.target.value + this.pickerInfoChioce.leftSph = this.pickerInfoList[0].nameArray1[e.target.value] + }, + bindPickerChange02: function(e) { + this.pickerInfoList[0].nameIndex2 = e.target.value + this.pickerInfoChioce.rightSph = this.pickerInfoList[0].nameArray2[e.target.value] + }, + + bindPickerChange11: function(e) { + this.pickerInfoList[1].nameIndex1 = e.target.value + this.pickerInfoChioce.leftCyl = this.pickerInfoList[1].nameArray1[e.target.value] + }, + bindPickerChange12: function(e) { + this.pickerInfoList[1].nameIndex2 = e.target.value + this.pickerInfoChioce.rightCyl = this.pickerInfoList[1].nameArray2[e.target.value] + }, + + bindPickerChange21: function(e) { + this.pickerInfoList[2].nameIndex1 = e.target.value + this.pickerInfoChioce.leftAxi = this.pickerInfoList[2].nameArray1[e.target.value] + }, + bindPickerChange22: function(e) { + this.pickerInfoList[2].nameIndex2 = e.target.value + this.pickerInfoChioce.rightAxi = this.pickerInfoList[2].nameArray2[e.target.value] + }, + + bindPickerChange41: function(e) { + this.pickerInfoList[3].nameIndex1 = e.target.value + this.pickerInfoChioce.time.year = this.pickerInfoList[3].nameArray1[e.target.value] }, - bindPickerChange01: function(e) { - this.pickerInfoList[0].nameIndex1 = e.target.value - this.pickerInfoChioce.leftSph=this.pickerInfoList[0].nameArray1[e.target.value] - }, - bindPickerChange02: function(e) { - this.pickerInfoList[0].nameIndex2 = e.target.value - this.pickerInfoChioce.rightSph=this.pickerInfoList[0].nameArray2[e.target.value] - }, - - bindPickerChange11: function(e) { - this.pickerInfoList[1].nameIndex1 = e.target.value - this.pickerInfoChioce.leftCyl=this.pickerInfoList[1].nameArray1[e.target.value] - }, - bindPickerChange12: function(e) { - this.pickerInfoList[1].nameIndex2 = e.target.value - this.pickerInfoChioce.rightCyl=this.pickerInfoList[1].nameArray2[e.target.value] - }, - - bindPickerChange21: function(e) { - this.pickerInfoList[2].nameIndex1 = e.target.value - this.pickerInfoChioce.leftAxi=this.pickerInfoList[2].nameArray1[e.target.value] - }, - bindPickerChange22: function(e) { - this.pickerInfoList[2].nameIndex2 = e.target.value - this.pickerInfoChioce.rightAxi=this.pickerInfoList[2].nameArray2[e.target.value] - }, - - bindPickerChange41: function(e) { - this.pickerInfoList[3].nameIndex1 = e.target.value - this.pickerInfoChioce.time.year=this.pickerInfoList[3].nameArray1[e.target.value] - }, - bindPickerChange42: function(e) { - this.pickerInfoList[3].nameIndex2 = e.target.value - this.pickerInfoChioce.time.month=this.pickerInfoList[3].nameArray2[e.target.value] - }, - bindPickerChange43: function(e) { - this.pickerInfoList[3].nameIndex3 = e.target.value - this.pickerInfoChioce.time.day=this.pickerInfoList[3].nameArray3[e.target.value] - }, - - change(num) { + bindPickerChange42: function(e) { + this.pickerInfoList[3].nameIndex2 = e.target.value + this.pickerInfoChioce.time.month = this.pickerInfoList[3].nameArray2[e.target.value] + }, + bindPickerChange43: function(e) { + this.pickerInfoList[3].nameIndex3 = e.target.value + this.pickerInfoChioce.time.day = this.pickerInfoList[3].nameArray3[e.target.value] + }, + changeShow(num) { this.show[num] = !this.show[num] this.$forceUpdate() }, @@ -583,24 +578,24 @@ export default { } this.$forceUpdate() }, - onClickItem1(index) { - if (this.current1 !== index) { - this.current1 = index - this.chooseRes1 = this.chooseItem1[index].describ - } - }, - onClickItem2(index) { - if (this.current2 !== index) { - this.current2 = index - this.chooseRes2 = this.chooseItem2[index].num - } - }, - onClickItem3(index) { - if (this.current3 !== index) { - this.current3 = index - this.chooseRes3 = this.chooseItem3[index] - } - }, + // onClickItem1(index) { + // if (this.current1 !== index) { + // this.current1 = index + // this.chooseRes1 = this.chooseItem1[index].describ + // } + // }, + // onClickItem2(index) { + // if (this.current2 !== index) { + // this.current2 = index + // this.chooseRes2 = this.chooseItem2[index].num + // } + // }, + // onClickItem3(index) { + // if (this.current3 !== index) { + // this.current3 = index + // this.chooseRes3 = this.chooseItem3[index] + // } + // }, counter(isadd) { if (isadd) { this.count >= this.maxCount ? this.addDisabled = true : this.count++ @@ -609,179 +604,174 @@ export default { } }, toComfirmOrder() { - // 先处理验光部分的逻辑,如果ok在跳转 - let flag=0; - if(this.name==''){ - uni.showToast({ - title:"请输入验光单取名", - icon: "none", - duration: 2000, - }) - }else{ - - if(this.pd==''){ - uni.showToast({ - title:"请输入瞳距", - icon: "none", - duration: 2000, - }) - }else{ - - if(this.kinds==1){ - // 添加用户验光单 - console.log('kinds====>',this.pickerInfoChioce.leftSph) - console.log('kinds====>',this.pickerInfoChioce.leftSph==Number) - console.log('kinds====>',this.pickerInfoChioce.rightSph==Number) - if(this.pickerInfoChioce.rightSph==''||this.pickerInfoChioce.leftSph==''|| - this.pickerInfoChioce.leftCyl==''||this.pickerInfoChioce.rightCyl==''|| - this.pickerInfoChioce.leftAxi==''||this.pickerInfoChioce.rightAxi=='' - ){ - uni.showToast({ - title:"请输入您的验光数据", - icon: "none", - duration: 2000, - }) - }else{ - if(this.confirm){ - store.dispatch('myLoveList/addMylove', { - uid: this.$store.state.user.userInfo.uid, - openid: this.$store.state.user.userInfo.openid, - // mp_name: this.$store.state.user.userInfo.mp_name, - leftSph: this.pickerInfoChioce.leftSph, - rightSph: this.pickerInfoChioce.rightSph, - leftCyl: this.pickerInfoChioce.leftCyl, - rightCyl: this.pickerInfoChioce.rightCyl, - leftAxi: this.pickerInfoChioce.leftAxi, - rightAxi: this.pickerInfoChioce.rightAxi, - pd: this.pd,// 瞳距 - mp_name:this.name, - // time: this.pickerInfoChioce.time, - // img_url2: "http://localhost:8087/images/shop_1/1/", - }); - flag=1 - } else{ - uni.showToast({ - title:"请确认您的验光数据", - icon: "none", - duration: 3000, - }) - } - } - } - if(this.kinds==2){ - // console.log('kinds====>',this.kinds) - // console.log('pickerindex=====>',this.pickerInfoList[0].nameIndex1) - // console.log('this.pickerInfoChioce====>',type(this.pickerInfoChioce)) - if(this.confirm){ - const leftList = ["leftSph","leftCyl","leftAxi"]; - const rightList = ["rightSph", "rightCyl", "rightAxi"]; - // let flag=0; - if(this.name!=this.oldname){ - store.dispatch('myLoveList/updateMylove', { - uid: this.$store.state.user.userInfo.uid, - openid: this.$store.state.user.userInfo.openid, - mp_id: this.mp_id, - keyname: 'name', - keyvalue: this.name, - }); - flag=1 - } - if(this.pd!=this.oldpd){ - store.dispatch('myLoveList/updateMylove', { - uid: this.$store.state.user.userInfo.uid, - openid: this.$store.state.user.userInfo.openid, - mp_id: this.mp_id, - keyname: 'pd', - keyvalue: this.pd, - }); - flag=1 - } - // 先验证是否输入有无空 - let q= true; - for(let k=0; k<3;k++){ - q=q&&(this.pickerInfoList[k].nameArray1[this.pickerInfoList[k].nameIndex1]!=''&& - this.pickerInfoList[k].nameArray2[this.pickerInfoList[k].nameIndex2]!='') - } - if(q){ - - for (let j=0; j<3; j++) { - if(this.pickerInfoList[j].nameIndex1!=0){ - store.dispatch('myLoveList/updateMylove', { - uid: this.$store.state.user.userInfo.uid, - openid: this.$store.state.user.userInfo.openid, - mp_id: this.mp_id, - keyname: leftList[j], - keyvalue: this.pickerInfoList[j].nameArray1[this.pickerInfoList[j].nameIndex1], - }); - } - if(this.pickerInfoList[j].nameIndex2!=0){ - store.dispatch('myLoveList/updateMylove', { - uid: this.$store.state.user.userInfo.uid, - openid: this.$store.state.user.userInfo.openid, - mp_id: this.mp_id, - keyname: rightList[j], - keyvalue: this.pickerInfoList[j].nameArray2[this.pickerInfoList[j].nameIndex2] - }); - } - flag=1; - } - }else{ - flag=0; - uni.showToast({ - title:"请输入您的验光数据", - icon: "none", - duration: 2000, - }) - - } - if(flag!=0){ - store.dispatch('myLoveList/getLoveList', { - uid: this.$store.state.user.userInfo.uid, - }); - } - - } else{ - uni.showToast({ - title:"请确认您的验光数据", - icon: "none", - duration: 3000, - }) - } - } - } - - } - if(flag!=0){ - // 如果数据验证无误,那么更新验光单的数据 - store.dispatch('myLoveList/getLoveList', { - uid: this.$store.state.user.userInfo.uid, - }); - let i = 0 - // 判断出是哪一个sku被选中 - for (let index = 0; index < this.current.length; index++) { - console.log('index', index, i, index !== this.current.length - 1) - if (index !== this.current.length - 1) { - console.log('----', this.current[index], this.attrList[1].attr.length, this.attrList) - i = this.current[index] * this.attrList[1].attr.length - } else { - i += this.current[index] - } - console.log('i', i) - } - console.log('i------>', i) - // 判断是否其输入的人员数据是否已存在 - store.dispatch('order/saveParams', { - sk_id_arr: this.skuList[i], - current: this.current - }) - - uni.navigateTo({ - url: `../confirmOrder/confirmOrder?pid=${this.pid}` - }) - } - - } - } + // 先处理验光部分的逻辑,如果ok在跳转 + let flag = 0 + if (this.name === '') { + uni.showToast({ + title: '请输入验光单取名', + icon: 'none', + duration: 2000, + }) + } else { + if (this.pd === '') { + uni.showToast({ + title: '请输入瞳距', + icon: 'none', + duration: 2000, + }) + } else { + if (this.kinds === 1) { + // 添加用户验光单 + console.log('kinds====>', this.pickerInfoChioce.leftSph) + console.log('kinds====>', this.pickerInfoChioce.leftSph === Number) + console.log('kinds====>', this.pickerInfoChioce.rightSph === Number) + if (this.pickerInfoChioce.rightSph === '' || this.pickerInfoChioce.leftSph === '' || + this.pickerInfoChioce.leftCyl === '' || this.pickerInfoChioce.rightCyl === '' || + this.pickerInfoChioce.leftAxi === '' || this.pickerInfoChioce.rightAxi === '' + ) { + uni.showToast({ + title: '请输入您的验光数据', + icon: 'none', + duration: 2000, + }) + } else { + if (this.confirm) { + store.dispatch('myLoveList/addMylove', { + uid: this.$store.state.user.userInfo.uid, + openid: this.$store.state.user.userInfo.openid, + // mp_name: this.$store.state.user.userInfo.mp_name, + leftSph: this.pickerInfoChioce.leftSph, + rightSph: this.pickerInfoChioce.rightSph, + leftCyl: this.pickerInfoChioce.leftCyl, + rightCyl: this.pickerInfoChioce.rightCyl, + leftAxi: this.pickerInfoChioce.leftAxi, + rightAxi: this.pickerInfoChioce.rightAxi, + pd: this.pd, // 瞳距 + mp_name: this.name, + // time: this.pickerInfoChioce.time, + // img_url2: "http://localhost:8087/images/shop_1/1/", + }).then(({ mp_id: mpId }) => { + this.mp_id = mpId + }) + flag = 1 + } else { + uni.showToast({ + title: '请确认您的验光数据', + icon: 'none', + duration: 3000, + }) + } + } + } + if (this.kinds === 2) { + // console.log('kinds====>',this.kinds) + // console.log('pickerindex=====>',this.pickerInfoList[0].nameIndex1) + // console.log('this.pickerInfoChioce====>',type(this.pickerInfoChioce)) + if (this.confirm) { + const leftList = ['leftSph', 'leftCyl', 'leftAxi'] + const rightList = ['rightSph', 'rightCyl', 'rightAxi'] + // let flag=0; + if (this.name !== this.oldname) { + store.dispatch('myLoveList/updateMylove', { + uid: this.$store.state.user.userInfo.uid, + openid: this.$store.state.user.userInfo.openid, + mp_id: this.mp_id, + keyname: 'name', + keyvalue: this.name, + }) + flag = 1 + } + if (this.pd !== this.oldpd) { + store.dispatch('myLoveList/updateMylove', { + uid: this.$store.state.user.userInfo.uid, + openid: this.$store.state.user.userInfo.openid, + mp_id: this.mp_id, + keyname: 'pd', + keyvalue: this.pd, + }) + flag = 1 + } + // 先验证是否输入有无空 + let q = true + for (let k = 0; k < 3; k++) { + q = q && (this.pickerInfoList[k].nameArray1[this.pickerInfoList[k].nameIndex1] !== '' && + this.pickerInfoList[k].nameArray2[this.pickerInfoList[k].nameIndex2] !== '') + } + if (q) { + for (let j = 0; j < 3; j++) { + if (this.pickerInfoList[j].nameIndex1 !== 0) { + store.dispatch('myLoveList/updateMylove', { + uid: this.$store.state.user.userInfo.uid, + openid: this.$store.state.user.userInfo.openid, + mp_id: this.mp_id, + keyname: leftList[j], + keyvalue: this.pickerInfoList[j].nameArray1[this.pickerInfoList[j].nameIndex1], + }) + } + if (this.pickerInfoList[j].nameIndex2 !== 0) { + store.dispatch('myLoveList/updateMylove', { + uid: this.$store.state.user.userInfo.uid, + openid: this.$store.state.user.userInfo.openid, + mp_id: this.mp_id, + keyname: rightList[j], + keyvalue: this.pickerInfoList[j].nameArray2[this.pickerInfoList[j].nameIndex2], + }) + } + flag = 1 + } + } else { + flag = 0 + uni.showToast({ + title: '请输入您的验光数据', + icon: 'none', + duration: 2000, + }) + } + if (flag !== 0) { + store.dispatch('myLoveList/getLoveList', { + uid: this.$store.state.user.userInfo.uid, + }) + } + } else { + uni.showToast({ + title: '请确认您的验光数据', + icon: 'none', + duration: 3000, + }) + } + } + } + } + if (flag !== 0) { + // 如果数据验证无误,那么更新验光单的数据 + store.dispatch('myLoveList/getLoveList', { + uid: this.$store.state.user.userInfo.uid, + }) + let i = 0 + // 判断出是哪一个sku被选中 + for (let index = 0; index < this.current.length; index++) { + console.log('index', index, i, index !== this.current.length - 1) + if (index !== this.current.length - 1) { + // 后续需修改算法:目前暂定只有两个参数选择,后续若有多个参数需要修改实现自适应 + i = this.current[index] * this.attrList[1].attr.length + } else { + i += this.current[index] + } + } + // 判断是否其输入的人员数据是否已存在 + store.dispatch('order/saveParams', { + sk_id_arr: this.skuList[i], + current: this.current, + mp_id: this.mp_id, + attrList: this.attrList, + }) + // 跳转到确认订单页面 + uni.navigateTo({ + url: `../confirmOrder/confirmOrder?pid=${this.pid}`, + }) + } + }, + }, } </script> @@ -927,7 +917,7 @@ export default { } } } - + // .goods-form { // display: flex; // flex-direction: column; @@ -1020,130 +1010,128 @@ export default { // } // } // } - .goods-form { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - background-color: #fff; - width: 100%; - padding: 40rpx 0; - .p1 { - font-size: 16px; - color: #333333; - letter-spacing: -0.3px; - text-align: justify; - line-height: 24px; - margin: 4px 0; - - } - .p2 { - font-size: 12px; - color: #999999; - letter-spacing: -0.23px; - margin-bottom: 32rpx; - } - .image2{ - width: 42rpx; - height: 34rpx; - margin-right: 12rpx; - } - .confirm { - display: flex; - align-items: center; - font-size: 12px; - color: #666666; - letter-spacing: -0.23px; - width: 684rpx; - .image1{ - margin-right:25rpx; - width: 42rpx; - height: 38rpx; - } - } - .picker{ - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - - .picker-choice{ - display: flex; - width: 684rpx; - align-items: center; - margin-bottom: 40rpx; - .input{ - border-bottom: 1px solid #CFCFCF; - height: 40rpx; - } - .choice-left{ - width: 210rpx; - .pd{ - font-size: 14px; - color: #333333; - letter-spacing: -0.26px; - text-align: justify; - line-height: 24px; - margin-right: 44rpx; - } - .p11 { - font-size: 14px; - color: #333333; - letter-spacing: -0.26px; - text-align: justify; - line-height: 24px; - // margin-right: 10px; - } - .p12 { - font-size: 10px; - color: #3F3F3F; - letter-spacing: -0.19px; - text-align: justify; - line-height: 24px; - } - - - } - .p13 { - font-size: 10px; - color: #999999; - letter-spacing: -0.19px; - margin-right: 10px; - } - .p13-date { - font-size: 10px; - color: #999999; - letter-spacing: -0.19px; - margin-right: 5px; - } - picker{ - width: 144rpx; - height: 40rpx; - display: flex; - position: relative; - .p14 { - font-size: 14px; - color: #666666; - letter-spacing: -0.26px; - text-align: center; - width: 124rpx; - border-bottom: 1px solid #CFCFCF; - height: 38rpx; - } - image{ - width: 20rpx; - height: 20rpx; - position: absolute; - right: 20rpx; - top: 8rpx; - } - } - - - } - } - } + .goods-form { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + background-color: #fff; + width: 100%; + padding: 40rpx 0; + .p1 { + font-size: 16px; + color: #333333; + letter-spacing: -0.3px; + text-align: justify; + line-height: 24px; + margin: 4px 0; + + } + .p2 { + font-size: 12px; + color: #999999; + letter-spacing: -0.23px; + margin-bottom: 32rpx; + } + .image2{ + width: 42rpx; + height: 34rpx; + margin-right: 12rpx; + } + .confirm { + display: flex; + align-items: center; + font-size: 12px; + color: #666666; + letter-spacing: -0.23px; + width: 684rpx; + .image1{ + margin-right:25rpx; + width: 42rpx; + height: 38rpx; + } + } + .picker{ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + + .picker-choice{ + display: flex; + width: 684rpx; + align-items: center; + margin-bottom: 40rpx; + .input{ + border-bottom: 1px solid #CFCFCF; + height: 40rpx; + } + .choice-left{ + width: 210rpx; + .pd{ + font-size: 14px; + color: #333333; + letter-spacing: -0.26px; + text-align: justify; + line-height: 24px; + margin-right: 44rpx; + } + .p11 { + font-size: 14px; + color: #333333; + letter-spacing: -0.26px; + text-align: justify; + line-height: 24px; + // margin-right: 10px; + } + .p12 { + font-size: 10px; + color: #3F3F3F; + letter-spacing: -0.19px; + text-align: justify; + line-height: 24px; + } + + } + .p13 { + font-size: 10px; + color: #999999; + letter-spacing: -0.19px; + margin-right: 10px; + } + .p13-date { + font-size: 10px; + color: #999999; + letter-spacing: -0.19px; + margin-right: 5px; + } + picker{ + width: 144rpx; + height: 40rpx; + display: flex; + position: relative; + .p14 { + font-size: 14px; + color: #666666; + letter-spacing: -0.26px; + text-align: center; + width: 124rpx; + border-bottom: 1px solid #CFCFCF; + height: 38rpx; + } + image{ + width: 20rpx; + height: 20rpx; + position: absolute; + right: 20rpx; + top: 8rpx; + } + } + + } + } + } } } .choose { diff --git a/src/store/modules/myLoveList.js b/src/store/modules/myLoveList.js index 27cefab..0d54f92 100644 --- a/src/store/modules/myLoveList.js +++ b/src/store/modules/myLoveList.js @@ -4,11 +4,11 @@ import request from '../request' const { mylovelist, myloveadd, - myloveupdate + myloveupdate, } = urlAlias const state = { - loveList: [] + loveList: [], } const mutations = { @@ -19,7 +19,7 @@ const mutations = { UPDATE: (state, data) => { // state.loveList.push(data) // console.log('UPDATA=====>',data) - } + }, } const actions = { @@ -30,20 +30,21 @@ const actions = { success: (res) => { // console.log(res.data); commit('INIT', res.data.data) - } + }, }) }, addMylove({ commit }, param) { console.log('myloveupdate-parm====>', param) - request({ + return new Promise((resolve) => request({ url: myloveadd, data: param, success: (res) => { console.log('addMylove-parm====>', param) console.log(res.data) + resolve(res.data) // commit("ADD", args); - } - }) + }, + })) }, updateMylove({ commit }, param) { request({ @@ -53,9 +54,9 @@ const actions = { console.log('myloveupdate-parm====>', param) console.log(res) // commit("UPDATE", param); - } + }, }) - } + }, } @@ -63,5 +64,5 @@ export default { namespaced: true, state, mutations, - actions + actions, } diff --git a/src/store/modules/order.js b/src/store/modules/order.js index d2a54c4..a7f4923 100644 --- a/src/store/modules/order.js +++ b/src/store/modules/order.js @@ -1,7 +1,7 @@ import urlAlias from '../url' import request from '../request' -const { orderBuild } = urlAlias +const { orderBuild, buyNow, pay } = urlAlias const state = { list: [], param: {} } @@ -11,34 +11,68 @@ const mutations = { }, SAVE: (state, param) => { state.param = param - } + }, } const actions = { + // 立即购买->创建订单 + buyNow({ commit }, param) { + return new Promise((resolve) => request({ + url: buyNow, + data: param, + success: (res) => { + resolve(res) + }, + fail: () => { + uni.showModal({ + content: '创建订单失败', + showCancel: false, + }) + }, + })) + }, + // 购物车->创建订单 build({ commit }, param) { return new Promise((resolve, reject) => request({ url: orderBuild, data: param, success: (res) => { - resolve() + resolve(res.data) }, fail: () => { uni.showModal({ content: '订单生成失败', - showCancel: false + showCancel: false, }) - } + }, })) }, + // 支付 + pay({ commit }, param) { + return new Promise((resolve, reject) => request({ + url: pay, + data: param, + success: (res) => { + resolve(res.data) + }, + fail: () => { + uni.showModal({ + content: '订单生成失败', + showCancel: false, + }) + }, + })) + }, + // 储存创建订单参数 saveParams({ commit }, param) { console.log('save', param) commit('SAVE', param) - } + }, } export default { namespaced: true, state, mutations, - actions + actions, } diff --git a/src/store/request.js b/src/store/request.js index 7a48f4a..205d77c 100644 --- a/src/store/request.js +++ b/src/store/request.js @@ -5,7 +5,7 @@ export default async function request({ method = 'post', data = {}, header = { - 'Content-Type': 'application/x-www-form-urlencoded' + 'Content-Type': 'application/x-www-form-urlencoded', }, timeout = 3000, withCredentials = false, // 跨域请求时是否携带凭证(cookies) @@ -16,14 +16,14 @@ export default async function request({ }, complete = (res) => { console.log('complete status === > ', res) - } + }, }) { const uid = uni.getStorageSync('uid') - const openid = uni.getStorageSync('uid') + const openid = uni.getStorageSync('openid') data = { uid, openid, - ...data + ...data, } uni .request({ @@ -35,6 +35,6 @@ export default async function request({ withCredentials, success, fail, - complete + complete, }) } diff --git a/src/store/url.js b/src/store/url.js index e7c8e4e..7a4c687 100644 --- a/src/store/url.js +++ b/src/store/url.js @@ -18,7 +18,9 @@ const urlAlias = { cancelOrder: '/app/order/wait/del', // 取消订单 statusConfirm: '/app/order/statusConfirm', // 订单操作 payLog: '/app/pay/log', // 调起支付 - orderBuild: '/app/order/build', // 生成订单 + orderBuild: '/app/order/build', // 加购后生成订单 + buyNow: '/app/order/buynow', // 立即购买生成订单 + pay: '/app/pay/log', // 支付接口 // 购物车 cartList: '/app/cart/list', // 获取购物车列表 @@ -43,7 +45,7 @@ const urlAlias = { // 用户数据 mylovelist: '/app/user/mylovelist', // 关心的人的数据 myloveadd: '/app/user/myloveadd', // 添加关心的人 - myloveupdate: '/app/user/myloveupdate' // 更新关心人的数据 + myloveupdate: '/app/user/myloveupdate', // 更新关心人的数据 } export default urlAlias -- 2.0.0