对接选择商品接口
parent
4ed701fa0f
commit
d0837aa8f7
|
|
@ -7,7 +7,6 @@ const whiteList = [
|
|||
|
||||
export default {
|
||||
created() {
|
||||
|
||||
// 登录判断跳转
|
||||
this.$u.routeAuth = (...args) => {
|
||||
let url = args[0]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<view class="text-txBase text-md price-text">{{goods.vip_price}}元 vip</view>
|
||||
<view v-if="isAdd" class="bg-hex-ef4444 text-center px-20rpx py-8rpx text-white rounded-10rpx" @click="add">添加</view>
|
||||
<view v-else>
|
||||
<u-number-box :min="1" :value="goods.num">
|
||||
<u-number-box :min="1" v-model="goods.num" @change="valChange">
|
||||
</u-number-box>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -27,19 +27,16 @@
|
|||
type:Object,
|
||||
default:()=>{}
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
goodsItem:{},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods:{
|
||||
//添加商品
|
||||
add(){
|
||||
this.$emit('addGood',this.goods.id)
|
||||
},
|
||||
//商品数量改变
|
||||
valChange(e){
|
||||
const {value}=e
|
||||
this.$emit('numChange',this.goods.id,value)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@
|
|||
<view class="flex flex-1 items-center justify-between">
|
||||
<view>默认已提货量》</view>
|
||||
<view>
|
||||
<u-number-box :min="1" :max="3" :value="1">
|
||||
<u-number-box :min="1" v-model="item.defaultNum" :max="item.num">
|
||||
</u-number-box>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<GoodsItem class="px-0" />
|
||||
<u-line v-if="list.length-1!=index" :hair-line="false" color="#c8c9cc"></u-line>
|
||||
<GoodsItem class="px-0" :goods="item" @numChange="numChange" />
|
||||
<u-line v-if="chooseList.length-1!=index" :hair-line="false" color="#c8c9cc"></u-line>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -39,11 +39,11 @@
|
|||
<view class="flex items-center">
|
||||
<view>
|
||||
合计
|
||||
<text class="ml-10rpx price-text text-hex-ef4444">15元</text>
|
||||
<text class="ml-10rpx price-text text-hex-ef4444">{{totalPrice}}元</text>
|
||||
</view>
|
||||
<view class="ml-10rpx">
|
||||
<view class="ml-10rpx">
|
||||
vip
|
||||
<text class="ml-10rpx price-text text-hex-ef4444">15元</text>
|
||||
<text class="ml-10rpx price-text text-hex-ef4444">{{vipPrice}}元</text>
|
||||
</view>
|
||||
</view>
|
||||
<view @click="$u.route('/pageB/code/index')"
|
||||
|
|
@ -81,9 +81,24 @@
|
|||
}) {
|
||||
this.id = id
|
||||
},
|
||||
computed:{
|
||||
//普通价格合计
|
||||
totalPrice(){
|
||||
const total=this.chooseList.reduce((pr, cu)=>{
|
||||
return pr+cu.sell_price*cu.num
|
||||
},0)
|
||||
return total
|
||||
},
|
||||
//会员价合计
|
||||
vipPrice(){
|
||||
const total=this.chooseList.reduce((pr, cu)=>{
|
||||
return pr+cu.vip_price*cu.num
|
||||
},0)
|
||||
return total
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async searchGoods() {
|
||||
this.isShow=false
|
||||
const resDate = await this.$api.get(`/v1/product/products`, {
|
||||
params: {
|
||||
keyword: this.keyword
|
||||
|
|
@ -93,21 +108,32 @@
|
|||
if (this.list.length == 0) {
|
||||
return this.$u.toast('暂未搜索到该商品')
|
||||
}
|
||||
this.isShow=false
|
||||
let goodsObj = resDate.data.length > 0 ? resDate.data[0] : {}
|
||||
goodsObj.defaultNum = 1
|
||||
goodsObj.defaultNum =1
|
||||
goodsObj.num = 1
|
||||
this.goodItem = goodsObj
|
||||
console.log( this.goodItem)
|
||||
},
|
||||
//添加商品
|
||||
addGood(e) {
|
||||
const result=this.chooseList.findIndex(item=> item.id=e)
|
||||
console.log(result);
|
||||
const result=this.chooseList.findIndex(item=> item.id==e)
|
||||
if(result==-1){
|
||||
this.chooseList.unshift(this.goodItem)
|
||||
}else{
|
||||
|
||||
const num= this.chooseList[result].num+1
|
||||
this.getUpdate(result,num)
|
||||
}
|
||||
},
|
||||
//商品数量改变
|
||||
numChange(id,value){
|
||||
const Index= this.chooseList.findIndex(item=>item.id==id)
|
||||
this.getUpdate(Index,value)
|
||||
},
|
||||
//刷新页面
|
||||
getUpdate(Index,val){
|
||||
this.chooseList[Index].num=val
|
||||
this.chooseList[Index].defaultNum=val
|
||||
this.chooseList=[...this.chooseList]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@
|
|||
<loading-view v-if="isFirstLoading"></loading-view>
|
||||
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
|
||||
:down="downOption" :up="upOption">
|
||||
<view class="grid grid-cols-2 gap-x-80rpx gap-y-40rpx pt-60rpx px-80rpx">
|
||||
<view @click="$u.route('/pageB/select_product/index',{id:item.id})" class="flex items-center justify-center flex-col"
|
||||
<view class="grid grid-cols-2 gap-x-80rpx pt-20rpx px-80rpx">
|
||||
<view @click="$u.route('/pageB/select_product/index',{id:item.id})" class="flex items-center justify-center flex-col mt-40rpx"
|
||||
v-for="(item,index) in dataList" :key="index">
|
||||
<!-- <view class="w-240rpx h-240rpx bg-hex-367fa9 bg-opacity-60"></view> -->
|
||||
<u-image class="flex-none" width="240" height="240" :src="item.image" :lazy-load="true">
|
||||
</u-image>
|
||||
<view class="mt-15rpx">{{item.title}}</view>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
<template>
|
||||
<view class="flex flex-col w-full min-h-full">
|
||||
<view class="flex-1">
|
||||
<view class="flex items-center justify-center py-100rpx">
|
||||
<view class="flex-1 translate-center w-full ">
|
||||
<!-- <view class="flex items-center justify-center py-100rpx">
|
||||
<image class="borderTop w-164rpx h-164rpx m-auto" src="/static/images/logs/logs.png" mode="aspectFill"></image>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="px-45rpx">
|
||||
<view class="px-45rpx ">
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<u-form :model="form" ref="uForm" :error-type="['toast']">
|
||||
<u-form-item prop="phone">
|
||||
<view class="flex items-center w-full">
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
</view>
|
||||
</u-form-item>
|
||||
</u-form>
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
|
||||
<view class="flex justify-between mt-45rpx">
|
||||
<text class="text-md" @tap="$u.route('/pageA/reset_password/login', { type: 0 })">忘记密码?</text>
|
||||
<text class="text-md text-primary" @tap="$u.route('/pages/register/index')">注册</text>
|
||||
|
|
@ -34,7 +35,7 @@
|
|||
<!-- #endif -->
|
||||
<view class="mt-90rpx">
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="login-btn" @tap="wxMpLogin"> 登录 </view>
|
||||
<!-- <view class="login-btn" @tap="wxMpLogin"> 登录 </view> -->
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view class="login-btn" @tap="onSubmit"> 登录 </view>
|
||||
|
|
@ -53,10 +54,10 @@
|
|||
</view>
|
||||
</view>
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view class="py-60rpx flex items-center flex-col justify-center text-txGray">
|
||||
<!-- <view class="py-60rpx flex items-center flex-col justify-center text-txGray">
|
||||
<view>子春生电子商务有限公司版权所有</view>
|
||||
<view @tap="$u.route('/pages/web_view/index', { url: 'https://beian.miit.gov.cn' })">渝ICP备2021010072号-2</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -92,7 +93,7 @@ export default {
|
|||
};
|
||||
},
|
||||
onReady() {
|
||||
this.$refs.uForm.setRules(this.rules);
|
||||
// this.$refs.uForm.setRules(this.rules);
|
||||
},
|
||||
async onLoad({ type, phone }) {
|
||||
this.form.phone = phone ?? '';
|
||||
|
|
@ -110,17 +111,14 @@ export default {
|
|||
|
||||
//微信快捷登录
|
||||
async getPhoneNumber(e) {
|
||||
const { encryptedData, iv } = e.detail;
|
||||
if(!iv) return
|
||||
const { code } = e.detail;
|
||||
if(!code) return
|
||||
const invite_code = uni.getStorageSync('INVITE_CODE');
|
||||
// const code = await getWxCode();
|
||||
const params = {}
|
||||
if(!!invite_code) params.inviter_code = invite_code
|
||||
const resData = await this.$api.post('/v1/socialite/code-bind-user/wechat-mini', {
|
||||
type: 'wechat-mini',
|
||||
code:this.code,
|
||||
iv,
|
||||
data: encryptedData,
|
||||
const resData = await this.$api.post('/v1/wechat-mini/bind-phone', {
|
||||
code:code,
|
||||
...params
|
||||
});
|
||||
this.LOGIN(resData.token);
|
||||
|
|
|
|||
|
|
@ -185,8 +185,9 @@
|
|||
<view class="w-710rpx bg-white px-base m-auto rounded-xs mt-base">
|
||||
<!-- 销售端 -->
|
||||
<view
|
||||
@tap="$u.route('/pageB/index/index')"
|
||||
@tap="$u.routeAuth('/pageB/index/index')"
|
||||
class="flex justify-between items-center py-base border-b border-txBorder"
|
||||
v-if="is_company"
|
||||
>
|
||||
<view class="flex items-center">
|
||||
<image class="w-32rpx h-32rpx" src="/static/images/user/my_account.png" mode=""></image>
|
||||
|
|
@ -275,9 +276,9 @@
|
|||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<block v-if="isLogin">
|
||||
<!-- <block v-if="isLogin">
|
||||
<view class="text-lg text-txBase w-710rpx h-100rpx bg-white m-auto rounded-xs mt-base text-center leading-100rpx" @tap="LogOut">退出登录</view>
|
||||
</block>
|
||||
</block> -->
|
||||
<view class="mt-40rpx">
|
||||
<view class="flex justify-center items-center">
|
||||
<view @tap="$u.route('/pages/web_view/index', { url: config.user_promotion_agreement })">服务协议</view>
|
||||
|
|
@ -357,6 +358,11 @@ export default {
|
|||
order_count() {
|
||||
return this.$store.getters.order_count ?? {};
|
||||
},
|
||||
//是否为店员
|
||||
is_company(){
|
||||
// return this.user?.is_company??false
|
||||
return true
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.$store.dispatch('user/getOrderNum');
|
||||
|
|
|
|||
|
|
@ -125,11 +125,11 @@
|
|||
<text class="text-black">运费</text>
|
||||
<text>¥{{ detail.shipping_fee }}</text>
|
||||
</view>
|
||||
<view class="h-50rpx leading-50rpx flex justify-between">
|
||||
<view class="h-50rpx leading-50rpx flex justify-between" v-if="detail.coupon_discount_amount > 0">
|
||||
<text class="text-black">优惠券</text>
|
||||
<text class="text-warning">-¥{{ detail.coupon_discount_amount }}</text>
|
||||
</view>
|
||||
<view class="h-50rpx leading-50rpx flex justify-between">
|
||||
<view class="h-50rpx leading-50rpx flex justify-between" v-if="detail.vip_discount_amount > 0">
|
||||
<text class="text-black">会员优惠</text>
|
||||
<text class="text-warning">-¥{{ detail.vip_discount_amount }}</text>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const getters = {
|
||||
isLogin: state => !!state.user.token,
|
||||
isLogin: state => !!state.user.user?.phone,
|
||||
token: state => state.user.token,
|
||||
user:state => state.user.user,
|
||||
allaccounts:state => state.user.allaccounts,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ const actions = {
|
|||
commit
|
||||
}) {
|
||||
/* #ifdef MP-WEIXIN */
|
||||
await http.post('/v1/socialite/unbind-user/wechat-mini')
|
||||
//await http.post('/v1/socialite/unbind-user/wechat-mini')
|
||||
/* #endif */
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/v1/logout', {}, {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ page {
|
|||
.translate-center {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
top: 40%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,13 @@ export async function wxMnpLogin(){
|
|||
|
||||
|
||||
async function silentLogin(data){
|
||||
const provider = 'wechat-mini'
|
||||
const resData = await http.post(`/v1/socialite/code-auth/${provider}`,data,{
|
||||
// const provider = 'wechat-mini'
|
||||
// const resData = await http.post(`/v1/socialite/code-auth/${provider}`,data,{
|
||||
// custom:{
|
||||
// toast:false
|
||||
// }
|
||||
// })
|
||||
const resData = await http.post(`/v1/wechat-mini/login`,data,{
|
||||
custom:{
|
||||
toast:false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue