6
0
Fork 0

对接生成二维码接口

hui.zhou
h30830569 2022-05-10 15:43:04 +08:00
parent d0837aa8f7
commit 203718afa5
6 changed files with 132 additions and 54 deletions

View File

@ -1,6 +1,6 @@
<template>
<view class="flex items-center justify-center flex-col pt-80rpx">
<image class="w-400rpx h-400rpx" src="http://zcs-test.oss-cn-chengdu.aliyuncs.com/product-spus/cover/2022-04-22/f6f96cba9ba86197e58ea3c2ce93b2a1.jpg" mode="scaleToFill"></image>
<image class="w-400rpx h-400rpx" :src="image"></image>
<view class="mt-20rpx">请用户通过微信扫码进入小程序生成订单</view>
<view class="grid grid-cols-2 gap-x-80rpx text-36rpx mt-120rpx">
<view @click="toBack"></view>
@ -13,9 +13,12 @@
export default {
data() {
return {
image:''
};
},
onLoad({image}) {
this.image=image
},
methods:{
toBack(){
uni.navigateBack({

View File

@ -23,12 +23,12 @@
<view class="flex flex-1 items-center justify-between">
<view>默认已提货量</view>
<view>
<u-number-box :min="1" v-model="item.defaultNum" :max="item.num">
<u-number-box :min="1" v-model="item.defaultNum" :max="item.num">
</u-number-box>
</view>
</view>
</view>
<GoodsItem class="px-0" :goods="item" @numChange="numChange" />
<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>
@ -41,13 +41,13 @@
合计
<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">{{vipPrice}}</text>
</view>
</view>
<view @click="$u.route('/pageB/code/index')"
class="bg-hex-ef4444 h-100rpx w-210rpx text-white text-center leading-100rpx ml-30rpx">生成二维码</view>
<view @click="qrCode" class="bg-hex-ef4444 h-100rpx w-210rpx text-white text-center leading-100rpx ml-30rpx">
生成二维码</view>
</view>
</block>
<!-- 无商品时 -->
@ -57,6 +57,9 @@
<view class="text-hex-909399 -mt-20rpx">请搜索您需要的商品</view>
</view>
</block>
<cu-modal v-model="modeShow" @confirm="confirm" confirm-color="#378264" show-cancel-button content="是否生成二维码?"
confirmText="确认" cancelText="再想想">
</cu-modal>
</view>
</template>
@ -68,12 +71,13 @@
},
data() {
return {
isShow:true,
modeShow: false,
isShow: true,
id: '',
keyword: '',
list: [], //
chooseList: [], //
goodItem:{},
goodItem: {},
};
},
onLoad({
@ -81,19 +85,19 @@
}) {
this.id = id
},
computed:{
computed: {
//
totalPrice(){
const total=this.chooseList.reduce((pr, cu)=>{
return pr+cu.sell_price*cu.num
},0)
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)
vipPrice() {
const total = this.chooseList.reduce((pr, cu) => {
return pr + cu.vip_price * cu.num
}, 0)
return total
}
},
@ -108,32 +112,72 @@
if (this.list.length == 0) {
return this.$u.toast('暂未搜索到该商品')
}
this.isShow=false
this.isShow = false
let goodsObj = resDate.data.length > 0 ? resDate.data[0] : {}
goodsObj.defaultNum =1
goodsObj.defaultNum = 1
goodsObj.num = 1
this.goodItem = goodsObj
},
//
addGood(e) {
const result=this.chooseList.findIndex(item=> item.id==e)
if(result==-1){
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)
} 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)
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]
getUpdate(Index, val) {
this.chooseList[Index].num = val
this.chooseList[Index].defaultNum = val
this.chooseList = [...this.chooseList]
},
qrCode() {
if (this.chooseList.length == 0) {
return this.$u.toast('至少选选择一件商品')
}
this.modeShow = true
},
//
async confirm() {
uni.showLoading({
title: '二维码生成中',
mask: true
});
try {
const arrList = this.chooseList.map(item => {
return {
sku_id: item.id,
quantity: item.num,
send: item.defaultNum
}
})
const obj = {
store_id: this.id,
products: arrList,
note: ''
}
const {
image
} = await this.$api.post(`/v1/order-pre`, obj);
this.$u.route('/pageB/code/index', {
image
})
this.keyword = ''
this.list = []
this.chooseList = []
this.goodItem = {}
this.isShow = true
} catch (err) {}finally{
uni.hideLoading()
}
}
}
}

View File

@ -45,7 +45,7 @@
</view>
<!-- -->
<view class="flex items-center justify-end bg-white shadow-up fixed right-0 left-0 bottom-0 cu-bar tabbar">
<view class="text-lg text-bgSubtitle mr-rowLg">-{{ discountCount }}</view>
<view class="text-lg text-bgSubtitle mr-rowLg" v-if="discountCount">-{{ discountCount }}</view>
<view class="text-md text-txBase">
合计: <text class="text-xl text-txSvip">{{ detail.total_amount }}</text>
</view>
@ -103,14 +103,14 @@ export default {
// name: '',
// pay_way: 'alipay',
// },
{
name: '可提',
pay_way: 'wallet',
},
{
name: '余额',
pay_way: 'balance',
},
// {
// name: '',
// pay_way: 'wallet',
// },
// {
// name: '',
// pay_way: 'balance',
// },
],
payWay: 'wxpay',
detail: {},

View File

@ -360,8 +360,7 @@ export default {
},
//
is_company(){
// return this.user?.is_company??false
return true
return this.user?.is_company??false
}
},
onShow() {

View File

@ -1,6 +1,6 @@
<template>
<view class="pt-24rpx">
<u-navbar>
<u-navbar :custom-back="goJump">
<view slot="right" class="flex items-center">
<!-- #ifndef MP-WEIXIN -->
<view class="px-18rpx relative" @tap="$u.route(`/pages/web_view/index?url=${service}`)">
@ -226,10 +226,9 @@ export default {
},
onLoad({ id }) {
this.id = id;
// this.getDetail();
},
onShow() {
this.getDetail();
this.getDetail();
},
computed: {
service() {
@ -244,6 +243,18 @@ export default {
},
},
methods: {
//
goJump(){
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]
if(prevPage){
uni.navigateBack({})
}else{
uni.switchTab({
url:'/pages/index/index'
})
}
},
//
copy(val) {
uniCopy({

View File

@ -1,25 +1,46 @@
<template>
<view>
</view>
</template>
<script>
import { strToParams } from '@/utils/tools';
import {
strToParams
} from '@/utils/tools';
export default {
data() {
return {
};
},
onLoad(e) {
const scene= strToParams(decodeURIComponent(e.scene))
if(scene.product){
console.log(e);
const scene = strToParams(decodeURIComponent(e.scene))
console.log(scene);
if (scene.product) {
uni.redirectTo({
url: '/pages/product_details/index?skuId=' + scene.product
})
uni.setStorageSync('INVITE_CODE', scene.code)
} else if (scene.order_pre) {
setTimeout(async () => {
uni.showLoading({
title: '加载中',
mask: true
});
const obj = {
id: scene.order_pre
}
const {
order_id
} = await this.$api.post(`/v1/order-pre/order`, obj)
uni.hideLoading()
uni.redirectTo({
url:'/pages/product_details/index?skuId='+scene.product
url: '/pages/order_details/index?id=' + order_id
})
uni.setStorageSync('INVITE_CODE',scene.code)
}
}, 1000)
}
},
}
</script>