暂时去掉登录时候client参数,会引发account唯一索引错误
This commit is contained in:
@ -104,7 +104,7 @@
|
||||
code: wxCode,
|
||||
nickname: nickName || '', //支付宝小程序没有直接获取昵称
|
||||
headimgurl: avatarUrl,
|
||||
client
|
||||
// client
|
||||
})
|
||||
if (code == 1) {
|
||||
if (data.is_new_user) {
|
||||
|
||||
@ -1,7 +1,91 @@
|
||||
<template>
|
||||
<view class="px32">
|
||||
<view class="bg-white br16 p24 row u-m-t-32">
|
||||
<view>
|
||||
<!-- 收货方式 -->
|
||||
<view class="bg-white br16 row u-m-t-32">
|
||||
<!-- <u-tabs
|
||||
:list="addressTabsList"
|
||||
:is-scroll="addressTabsList.length === 1"
|
||||
:current="addressTabsIndex"
|
||||
:active-color="primaryColor"
|
||||
bar-width="100"
|
||||
:bar-style="{ top: '100%' }"
|
||||
@change="changeDelivery"
|
||||
/> -->
|
||||
<!-- 快递配送 -->
|
||||
<view
|
||||
v-show="addressTabsList[addressTabsIndex]['sign'] === 'express'"
|
||||
class="u-flex p24 w-full"
|
||||
@click="onAddressExpress"
|
||||
>
|
||||
<view>
|
||||
<u-icon name="map" size="48" class="right-icon"></u-icon>
|
||||
</view>
|
||||
<view class="u-flex flex1 u-row-between">
|
||||
<view class="ml10">
|
||||
<template v-if="address.id">
|
||||
<view class="md black bold">
|
||||
<text>{{ address.contact }}</text>
|
||||
<text class="ml10">{{ address.telephone }}</text>
|
||||
</view>
|
||||
<view class="xs black mt10">{{
|
||||
address.province +
|
||||
address.city +
|
||||
address.district +
|
||||
address.address
|
||||
}}</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>请选择收货地址</view>
|
||||
</template>
|
||||
</view>
|
||||
<view >
|
||||
<u-icon class="ml10" name="arrow-right" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 门店自提 -->
|
||||
<!-- <view
|
||||
v-show="addressTabsList[addressTabsIndex]['sign'] === 'store'"
|
||||
class="receiving-card"
|
||||
@click="onAddressStore"
|
||||
>
|
||||
<u-image
|
||||
class="icon-md mr20"
|
||||
width="44"
|
||||
height="44"
|
||||
src="/static/images/icon_address.png"
|
||||
mode="scaleToFill"
|
||||
/>
|
||||
<view class="receiving-content">
|
||||
<template v-if="storeInfo.id">
|
||||
<text class="md black bold">{{ storeInfo.name }}</text>
|
||||
<text class="xs black mt10">{{ storeInfo.shop_address }}</text>
|
||||
<text class="xs muted mt10">
|
||||
<text>营业时间:</text>
|
||||
<text
|
||||
>{{ storeInfo.business_start_time }} -
|
||||
{{ storeInfo.business_end_time }}</text
|
||||
>
|
||||
</text>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view>请选择门店地址</view>
|
||||
</template>
|
||||
</view>
|
||||
<u-icon name="arrow-right" />
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="bg-white br16 row u-m-t-32">
|
||||
<order-goods
|
||||
:team="{ need: orderInfo.team_need }"
|
||||
:list="goodsLists"
|
||||
:delivery="delivery"
|
||||
:order_type="orderInfo.order_type"
|
||||
:imageWidth="260"
|
||||
:imageHeight="172"
|
||||
mode="comfirm"
|
||||
></order-goods>
|
||||
<!-- <view>
|
||||
<u-image :src="cloudPath + 'img/banner.png'" width="260" height="172"></u-image>
|
||||
</view>
|
||||
<view class="ml20 flex1">
|
||||
@ -18,7 +102,7 @@
|
||||
</view>
|
||||
<view class="num nr">X1</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="bg-white br16 p24 u-m-t-32">
|
||||
@ -97,6 +181,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { orderBuy, getOrderCoupon, getDelivery } from '@/api/order'
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
@ -106,10 +191,35 @@
|
||||
alipay: 0
|
||||
},
|
||||
showLoading: false, // Loading: 显示 | 隐藏
|
||||
goods: {}, // 商品信息
|
||||
// 地址Tabs列表
|
||||
addressTabsList: [
|
||||
{
|
||||
id: 1,
|
||||
sign: 'express',
|
||||
name: '快递配送'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
sign: 'store',
|
||||
name: '门店自提'
|
||||
}
|
||||
],
|
||||
addressTabsIndex: 0, // 地址Tabs索引
|
||||
goodsLists: [], // 商品列表
|
||||
orderInfo: {}, // 订单信息
|
||||
address: {}, // 收货地址信息
|
||||
addressId: '', // 收货地址ID
|
||||
storeInfo: {}, // 门店信息
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
console.log("this.$>>>", this.$store.state.goods.buyGoods);
|
||||
const data = JSON.parse(decodeURIComponent(options.data))
|
||||
console.log("data>>>", data);
|
||||
this.goods = data.goods
|
||||
|
||||
//#ifdef MP-WEIXIN
|
||||
this.pay.weixin = 1
|
||||
//#endif
|
||||
@ -117,12 +227,93 @@
|
||||
//#ifdef MP-ALIPAY
|
||||
this.pay.alipay = 1
|
||||
//#endif
|
||||
|
||||
// 配送方式
|
||||
getDelivery()
|
||||
.then(({ code, data, msg }) => {
|
||||
// 请求结果判断
|
||||
if (code != 1) throw new Error(msg)
|
||||
return data
|
||||
})
|
||||
.then((data) => {
|
||||
// 快递
|
||||
if (!data.is_express) {
|
||||
this.addressTabsList = this.addressTabsList.filter(
|
||||
(item) => item.sign !== 'express'
|
||||
)
|
||||
}
|
||||
// 自提
|
||||
if (!data.is_selffetch) {
|
||||
this.addressTabsList = this.addressTabsList.filter(
|
||||
(item) => item.sign !== 'store'
|
||||
)
|
||||
}
|
||||
})
|
||||
// 页面数据初始化
|
||||
.then(() => {
|
||||
this.handleOrderMethods('info')
|
||||
this.initCouponData()
|
||||
})
|
||||
// 监听全局事件
|
||||
.then(() => {
|
||||
uni.$on('selectaddress', (params) => {
|
||||
this.addressId = params.id
|
||||
this.handleOrderMethods('info')
|
||||
})
|
||||
|
||||
uni.$on('payment', (params) => {
|
||||
setTimeout(() => {
|
||||
uni.$off('payment')
|
||||
|
||||
if (params.result) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/pay_result/pay_result?id=${params.order_id}`
|
||||
})
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: '/pages/user_order/user_order'
|
||||
})
|
||||
}
|
||||
}, 500)
|
||||
})
|
||||
|
||||
uni.$on('store', (params) => {
|
||||
this.storeInfo = params
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
// 取消全局监听
|
||||
uni.$off(['selectaddress', 'store'])
|
||||
},
|
||||
|
||||
methods: {
|
||||
appointmentTime() {
|
||||
this.timePopup = true
|
||||
},
|
||||
|
||||
// 初始化优惠券数据
|
||||
initCouponData() {
|
||||
getOrderCoupon({
|
||||
goods: this.goods
|
||||
})
|
||||
.then(({ code, data, msg }) => {
|
||||
if (code != 1) throw new Error(msg)
|
||||
return data
|
||||
})
|
||||
.then((data) => {
|
||||
this.usableCoupon = data.usable
|
||||
this.unusableCoupon = data.unusable
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
|
||||
// 点击订单提交
|
||||
onSubmitOrder() {
|
||||
uni.showModal({
|
||||
@ -137,6 +328,72 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 订单处理
|
||||
handleOrderMethods(action) {
|
||||
// 订单提交数据
|
||||
const orderFrom = {
|
||||
action,
|
||||
goods: this.goods,
|
||||
delivery_type: this.delivery,
|
||||
use_integral: this.useIntegral,
|
||||
address_id: this.addressId,
|
||||
coupon_id: this.couponId,
|
||||
bargain_launch_id: this.bargainLaunchId == -1 ? '' : this.bargainLaunchId
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case 'info':
|
||||
this.initPageData(orderFrom)
|
||||
break
|
||||
case 'submit':
|
||||
this.handleOrderSubmit(orderFrom)
|
||||
break
|
||||
}
|
||||
},
|
||||
|
||||
// 初始化页面数据
|
||||
async initPageData(from) {
|
||||
this.showLoading = true
|
||||
|
||||
try {
|
||||
const { code, data, msg } = await orderBuy(from)
|
||||
|
||||
if (code == 1) {
|
||||
this.address = data.address
|
||||
this.goodsLists = data.goods_lists
|
||||
//TODO
|
||||
if (data.selffetch_info) {
|
||||
this.storeInfo = data.selffetch_info.selffetch_shop
|
||||
? data.selffetch_info.selffetch_shop
|
||||
: {}
|
||||
this.userConsignee = data.selffetch_info.contact
|
||||
this.userMobile = data.selffetch_info.mobile
|
||||
}
|
||||
|
||||
this.orderInfo = data
|
||||
this.$nextTick(() => {
|
||||
this.isFirstLoading = false
|
||||
})
|
||||
} else {
|
||||
throw new Error(msg)
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
this.$toast({ title: '网络异常,请重新进入页面' })
|
||||
} finally {
|
||||
this.showLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 点击选择收货地址
|
||||
onAddressExpress() {
|
||||
uni.navigateTo({
|
||||
url: `/bundle/pages/address/address?type=${1}`
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 订单处理
|
||||
// handleOrderMethods(action) {
|
||||
@ -185,7 +442,12 @@
|
||||
// this.showLoading = false
|
||||
// }
|
||||
// },
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
delivery() {
|
||||
return this.addressTabsList[this.addressTabsIndex]['id']
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
<view>门店</view>
|
||||
</view>
|
||||
<view class="u-m-l-64 flex1">
|
||||
<u-button hover-class="none" @click="onBuy"
|
||||
<u-button hover-class="none" @click="showSpecFun"
|
||||
:customStyle="{height: '92rpx', fontSize: '24rpx', backgroundColor: themeColor, color: '#fff', border: 'none', paddingTop: '8rpx'}"
|
||||
:hair-line="false"
|
||||
shape="circle">
|
||||
@ -78,7 +78,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<shop-spec v-model="showSpec" :name="goods.name" :spec="goods.goods_spec" @close="showSpec = false" @confirm="confirmSpec"></shop-spec>
|
||||
<shop-spec v-model="showSpec" :name="goods.name" :goods="goods" @close="showSpec = false" @confirm="confirmSpec" @buynow="onBuy"></shop-spec>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -100,6 +100,7 @@
|
||||
showSpec: false,
|
||||
goods: [],
|
||||
spec: [],
|
||||
checkedGoods: {},
|
||||
}
|
||||
},
|
||||
|
||||
@ -139,20 +140,25 @@
|
||||
this.showSpec = false
|
||||
},
|
||||
|
||||
// 购买商品
|
||||
onBuy() {
|
||||
// 这里需压判断选购规格
|
||||
if (!this.isLogin) return toLogin();
|
||||
this.$store.commit("setBuyGoods", {
|
||||
id: this.id, // 商品id
|
||||
num: 1, // 购买商品数量
|
||||
spec: this.spec // 选中的商品规格
|
||||
});
|
||||
onChangeGoods(e) {
|
||||
console.log(e);
|
||||
this.checkedGoods = e.detail;
|
||||
},
|
||||
|
||||
// console.log("this.$>>>", this.$store.state.goods.buyGoods);
|
||||
|
||||
// 选择规格
|
||||
showSpecFun() {
|
||||
if (!this.isLogin) return toLogin();
|
||||
this.showSpec = true;
|
||||
},
|
||||
|
||||
// 购买商品
|
||||
onBuy(e) {
|
||||
let {id, goodsNum} = e.detail
|
||||
let goods = [{item_id: id, num: goodsNum}]
|
||||
const params = {goods}
|
||||
this.showSpec = false
|
||||
uni.navigateTo({
|
||||
url: `/pages/order_now/order_now`
|
||||
url: '/pages/order_now/order_now?data=' + encodeURIComponent((JSON.stringify(params)))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-l-24">
|
||||
<u-button @click="mpLogin" hover-class="none" :customStyle="{width: '228rpx', height: '80rpx', backgroundColor: themeColor, color: '#fff', border: 'none', padding: '16rpx 0', borderRadius: '64rpx'}" :hair-line="false">结算</u-button>
|
||||
<u-button @click="goToConfirm" hover-class="none" :customStyle="{width: '228rpx', height: '80rpx', backgroundColor: themeColor, color: '#fff', border: 'none', padding: '16rpx 0', borderRadius: '64rpx'}" :hair-line="false">结算</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -175,6 +175,11 @@
|
||||
});
|
||||
},
|
||||
|
||||
// 选择单个商品
|
||||
changOneSelect(cartId, selected) {
|
||||
selected = !selected;
|
||||
this.changeCartSelectFun([cartId], selected);
|
||||
},
|
||||
|
||||
// 更改全选状态
|
||||
changeAllSelect() {
|
||||
@ -200,10 +205,8 @@
|
||||
|
||||
// 去结算
|
||||
goToConfirm() {
|
||||
let {
|
||||
cartLists
|
||||
} = this;
|
||||
let goods = [];
|
||||
let {cartLists} = this
|
||||
let goods = []
|
||||
cartLists.forEach((item) => {
|
||||
if (item.selected && item.cart_status == 0) {
|
||||
goods.push({
|
||||
@ -212,19 +215,20 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
if (goods.length == 0)
|
||||
return this.$toast({
|
||||
title: "您还没有选择商品哦",
|
||||
});
|
||||
uni.navigateTo({
|
||||
url: "/pages/confirm_order/confirm_order?data=" +
|
||||
encodeURIComponent(
|
||||
JSON.stringify({
|
||||
goods,
|
||||
type: "cart",
|
||||
})
|
||||
),
|
||||
console.log("this.cartList>>>", goods);
|
||||
|
||||
if (goods.length == 0) return this.$toast({
|
||||
title: "您还没有选择商品哦",
|
||||
});
|
||||
// uni.navigateTo({
|
||||
// url: "/pages/confirm_order/confirm_order?data=" +
|
||||
// encodeURIComponent(
|
||||
// JSON.stringify({
|
||||
// goods,
|
||||
// type: "cart",
|
||||
// })
|
||||
// ),
|
||||
// });
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user