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

@ -46,8 +46,8 @@
<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,6 +71,7 @@
},
data() {
return {
modeShow: false,
isShow: true,
id: '',
keyword: '',
@ -134,6 +138,46 @@
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,7 +226,6 @@ export default {
},
onLoad({ id }) {
this.id = id;
// this.getDetail();
},
onShow() {
this.getDetail();
@ -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

@ -5,7 +5,9 @@
</template>
<script>
import { strToParams } from '@/utils/tools';
import {
strToParams
} from '@/utils/tools';
export default {
data() {
return {
@ -13,12 +15,31 @@
};
},
onLoad(e) {
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/order_details/index?id=' + order_id
})
}, 1000)
}
},
}