授权逻辑优化;增加确认订单页面

main
xuechunyuan 3 years ago
parent 42c2aed817
commit 4fa9de1f46
  1. 2
      App.vue
  2. 16
      pages.json
  3. 85
      pages/pages_zhentou/homePage/homePage.vue
  4. 23
      pages/pages_zhentou/myPage/myPage.vue
  5. 441
      pages/pages_zhentou/order/confirmOrder.vue
  6. 10
      pages/pages_zhentou/order/order.vue
  7. BIN
      static/image/icon_jian.png
  8. BIN
      static/image/icon_jian01.png
  9. BIN
      static/image/icon_plus.png

@ -62,6 +62,7 @@
test: '',
// baseUrl: "http://192.168.3.32:80",
baseUrl: "http://192.168.1.106:80",
// baseUrl: "http://47.104.224.41:80",//
imgPrefix: "http://47.104.224.41:9000/etriphome/appresource/image/", //
},
methods: {
@ -76,7 +77,6 @@
if (res.data.code == 200) {
if (JSON.stringify(res.data.data) != '{}') {
uni.setStorageSync('userInfo', JSON.stringify(res.data.data));
uni.setStorageSync('phone', res.data.data.phone);
this.doLogin(res.data.data.username, res.data.data.phone);
}
} else {

@ -158,6 +158,22 @@
}
}
}
},
{
"path": "pages/pages_zhentou/order/confirmOrder",
"style": {
"navigationBarTitleText": "提交订单",
"app-plus": {
"titleNView": {
// "buttons": [{
// "text": "\ue534",
// "fontSrc": "/static/uni.ttf",
// "fontSize": "22px",
// "color": "#FFFFFF"
// }]
}
}
}
}
],
// "subPackages": [{

@ -14,8 +14,7 @@
</view>
<view class="bottom_box">
<!-- <button class="btn" @click="addForm">填写报名单其他渠道已购买</button> -->
<button class="btn" v-if="!hasUserInfo &&canIUseGetUserProfile" @click="getUserProfile">立即定制</button>
<button v-else-if="!hasPhone" open-type="getPhoneNumber" class="btn"
<button v-if="!hasPhone" open-type="getPhoneNumber" class="btn"
@getphonenumber="getPhoneNumber">立即定制</button>
<button v-else class="btn" @click="clickCustom">立即定制</button>
</view>
@ -27,26 +26,19 @@
data() {
return {
userInfo: {},
hasUserInfo: false,
canIUseGetUserProfile: false,
phone: '',
hasPhone: false,
bgSrc: '', //
}
},
onShow() {
if (wx.getUserProfile) {
this.canIUseGetUserProfile = true;
}
let phone = uni.getStorageSync('phone');
let userInfo = uni.getStorageSync('userInfo');
if (phone) {
this.phone = phone;
this.hasPhone = true;
}
if (userInfo) {
this.userInfo = JSON.parse(userInfo);
this.hasUserInfo = true;
if(this.userInfo.phone) {
this.phone = this.userInfo.phone;
this.hasPhone = true;
}
}
//
if (this.bgSrc == '') {
@ -57,7 +49,7 @@
//
queryGoodsInfo() {
uni.request({
url: 'http://192.168.1.106:80/blade-system/dict-biz/get-goods-info',
url: getApp().globalData.baseUrl + '/blade-system/dict-biz/get-goods-info',
method: 'GET',
success: (res) => {
if (JSON.stringify(res.data.data) !== '{}') {
@ -71,46 +63,8 @@
//
clickCustom() {
console.log('点击定制');
uni.request({
url: getApp().globalData.baseUrl + '/blade-desk/order/save',
method: 'POST',
data: {
buyerId: this.userInfo.id,
buyerName: this.userInfo.username,
buyerPhone: this.phone
},
header: {
'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
},
success: (res) => {
if (res.data.code == 200) {
console.log('下单成功');
uni.navigateTo({
url: '/pages/pages_zhentou/order/order'
})
} else if (res.data.code == 401) {
this.doLogin();
} else if (res.data.code == 1001) {
uni.showModal({
title: '提示',
content: res.data.msg,
success: (res2) => {
if (res2.confirm) {
uni.navigateTo({
url: '/pages/pages_zhentou/order/order'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}
uni.navigateTo({
url: '/pages/pages_zhentou/order/confirmOrder'
})
},
//
@ -121,33 +75,10 @@
},
//
addForm() {
// console.log('')
// uni.navigateTo({
// url: '/pages/pages_zhentou//form/form'
// });
uni.switchTab({
url: '/pages/pages_zhentou/form/form'
});
},
//
getUserProfile() {
uni.getUserProfile({
lang: 'zh_CN',
desc: '获取微信用户的昵称和头像',
success: (res) => {
console.log(res)
this.userInfo = res.userInfo;
this.hasUserInfo = true;
if (this.phone) {
//
this.doSave();
}
},
fail: (err) => {
console.log(err)
}
})
},
//
getPhoneNumber(e) {
console.log(e, '获取手机号授权')

@ -1,8 +1,11 @@
<template>
<view>
<view class="person_box">
<image :src="userInfo.avatar" class="avatar"></image>
<view class="nickname">{{userInfo.username}}</view>
<image v-if="userInfo.avatar" :src="userInfo.avatar" class="avatar"></image>
<button v-else open-type="chooseAvatar" @chooseavatar="chooseavatar" class="avatar"></button>
<view class="nickname">
{{userInfo.username}}
</view>
</view>
<view class="cnt-box">
<view class="title">用户功能</view>
@ -23,7 +26,7 @@
<view class="li_box" @click="returnContact">
<view class="li_left">
<image src="../../../static/image/icon-contact.png" style="width: 40rpx; height: 40rpx;margin-right: 13rpx;"></image>
服务
服务
</view>
<image src="../../../static/image/icon-arrow-right.png" style="width: 40rpx; height: 40rpx;"></image>
</view>
@ -35,20 +38,24 @@
export default {
data() {
return {
userInfo: {}
userInfo: {
username: '',
avatar: ''
}
}
},
onShow() {
let userInfo = uni.getStorageSync('userInfo');
if (userInfo) {
this.userInfo = JSON.parse(userInfo);
if(this.userInfo.id == undefined) {
this.userInfo.avatar = this.userInfo.avatarUrl;
this.userInfo.username = this.userInfo.nickName;
}
}
},
methods: {
//
chooseavatar() {
const { avatarUrl } = e.detail
this.userInfo.avatar = avatarUrl;
},
returnOrder(){
uni.navigateTo({
url:"/pages/pages_zhentou/order/order"

@ -0,0 +1,441 @@
<template>
<view class="order_box">
<view class="order_address">
<view class="address_info">
<view class="address_top" v-if="address">
<view class="isflag">默认</view>
<view class="txt">山东省青岛市市北区</view>
</view>
<view class="address_des" v-if="address">大港街道大港三路8号铁路住宅小区6号楼6单元666室</view>
<view class="address_des" style="color: #666;font-weight: normal;" v-else>请填写收货地址</view>
<view class="address_user" v-if="address">
<text class="user_name">1d</text>
<text class="user_phone">15612345678</text>
</view>
</view>
<image @click="goAddress" class="arrow" src="../../../static/image/icon-arrow-right.png"></image>
</view>
<view class="order_content">
<view class="order_item">
<view class="top_title">
<p class="title">壹人壹枕</p>
</view>
<view class="top_content">
<view class="left_cont">
<image class="img_box" :src="imgPrefix + 'zhentou_bag.png'" mode=""></image>
</view>
<view class="right_cont">
<p class="right_title">{{goodsInfo.goodsName}}</p>
<p class="bot_right">
<span style="font-size: 22rpx;color: #666;">{{orderInfo.goodsNum}}</span>
<span>
<span style="font-size: 22rpx;color: #333;"></span><span
style="font-size: 28rpx;color: #333;">{{goodsInfo.price}}</span>
</span>
</p>
</view>
</view>
<view class="order_num">
<view class="num_title">购买数量</view>
<view class="goods_num_btn">
<image v-if="orderInfo.goodsNum == 1" class="act_img" src="../../../static/image/icon_jian.png"></image>
<image v-else @click="doJian" class="act_img" src="../../../static/image/icon_jian01.png"></image>
<view class="goods_num">{{orderInfo.goodsNum}}</view>
<image @click="doPlus" class="act_img" src="../../../static/image/icon_plus.png"></image>
</view>
</view>
</view>
</view>
<!-- 总计 -->
<view class="goods_sum">
<view class="sum_title">
<text>共计</text>
<view class="price">
<text class="price_unit"></text>
<text class="price">{{totalPrice}}</text>
</view>
</view>
<view @click="submitOrder" class="order_btn">立即支付</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
imgPrefix: getApp().globalData.imgPrefix,
phone: '',
address: null,
goodsInfo: {
goodsName: '',
price: 699
},
userInfo: {},
orderInfo: {
goodsNum: 1
},
totalPrice: 699
}
},
onLoad() {
let userInfo = uni.getStorageSync('userInfo');
if(userInfo) {
this.userInfo = JSON.parse(userInfo);
this.phone = this.userInfo.phone;
this.queryAddress();
}
this.queryGoodsInfo();
},
methods: {
//
changeAddress(address) {
this.address = address;
},
//
goAddress() {
uni.navigateTo({
url: '/pages/pages_zhentou/myPage/address?from=1'
})
},
//
doJian() {
this.orderInfo.goodsNum = this.orderInfo.goodsNum > 1 ? this.orderInfo.goodsNum - 1 : this.orderInfo.goodsNum;
this.calcPrice();
},
doPlus() {
this.orderInfo.goodsNum = this.orderInfo.goodsNum + 1;
this.calcPrice();
},
//
calcPrice() {
this.totalPrice = Number(this.orderInfo.goodsNum) * Number(this.goodsInfo.price)
},
//
queryGoodsInfo() {
uni.request({
url: getApp().globalData.baseUrl + '/blade-system/dict-biz/get-goods-info',
method: 'GET',
success: (res) => {
this.goodsInfo = res.data.data;
this.totalPrice = res.data.data.price;
}
})
},
//
queryAddress() {
uni.request({
url: getApp().globalData.baseUrl + '/address/get-default-address?phone=' + this.phone,
method: 'GET',
header: {
'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
},
success: (res) => {
if (res.data.code == 200) {
console.log('下单成功');
} else if (res.data.code == 401) {
this.doLogin();
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}
})
},
//
submitOrder() {
if(!this.address) {
uni.showToast({
title: '请填写收货地址',
icon: 'none'
})
return;
}
uni.request({
url: getApp().globalData.baseUrl + '/blade-desk/order/save',
method: 'POST',
data: {
buyerId: this.userInfo.id,
buyerName: this.userInfo.username,
buyerPhone: this.phone,
goodsNum: this.orderInfo.goodsNum
},
header: {
'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
},
success: (res) => {
if (res.data.code == 200) {
this.address = JSON.stringify(res.data.data) == '{}' ? null : res.data.data;
} else if (res.data.code == 401) {
this.doLogin();
} else if (res.data.code == 1001) {
uni.showModal({
title: '提示',
content: res.data.msg,
success: (res2) => {
if (res2.confirm) {
uni.navigateTo({
url: '/pages/pages_zhentou/order/order'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}
})
},
//
doLogin() {
uni.showLoading({
title: '登录中',
mask: true
});
uni.request({
url: getApp().globalData.baseUrl + '/blade-auth/getToken',
method: 'POST',
data: {
openId: getApp().globalData.openId,
username: this.userInfo.username,
phone: this.phone
},
header: {
'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0'
},
success: (res) => {
if (res.data.code == 200) {
uni.setStorageSync('token', res.data.data.access_token);
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
},
complete: () => {
uni.hideLoading();
}
})
}
}
}
</script>
<style lang="scss" scoped>
.order_box {
.order_address{
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx 17rpx 30rpx 27rpx;
margin: 30rpx 30rpx 18rpx;
background-color: #fff;
border-radius: 30rpx;
.arrow{
width: 40rpx;
height: 40rpx;
}
.address_info{
width: 554rpx;
.address_top{
display: flex;
align-items: center;
.isflag{
width: 60rpx;
color: #D73232;
font-size: 20rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
line-height: 30rpx;
text-align: center;
background: #FFFFFF;
border-radius: 10rpx;
border: 1rpx solid #D73232;
}
.txt{
line-height: 32rpx;
font-size: 24rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
margin-left: 12rpx;
}
}
.address_des{
line-height: 40rpx;
font-size: 28rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #333333;
word-break: break-all;
margin: 20rpx 0;
}
.address_user{
display: flex;
align-items: center;
line-height: 33rpx;
font-size: 24rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
.user_name{
color: #333333;
}
.user_phone{
color: #999999;
margin-left: 10rpx;
}
}
}
}
.order_content {
width: 100%;
height: auto;
overflow-y: auto;
.order_item {
width: 690rpx;
background: #FFFFFF;
border-radius: 30rpx;
margin: 0 auto;
margin-top: 30rpx;
padding-bottom: 30rpx;
.top_title {
padding: 30rpx 31rpx 25rpx;
display: flex;
justify-content: space-between;
.title {
font-size: 28rpx;
}
.status_txt {
font-size: 24rpx;
}
}
.top_content {
width: 630rpx;
height: 160rpx;
background: #F8F8F8;
border-radius: 20rpx;
margin: 0 auto;
display: flex;
.left_cont {
width: 160rpx;
height: 160rpx;
.img_box {
width: 100%;
height: 100%;
}
}
.right_cont {
width: 470rpx;
padding: 0rpx 30rpx;
.right_title {
margin-top: 20rpx;
font-size: 26rpx;
}
.bot_right {
margin-top: 49rpx;
display: flex;
justify-content: space-between;
}
}
}
.order_num{
display: flex;
justify-content: space-between;
color: #333333;
font-family: PingFang SC-Regular, PingFang SC;
line-height: 38rpx;
padding: 30rpx 30rpx 0;
.num_title{
font-size: 26rpx;
font-weight: 400;
}
.goods_num_btn{
display: flex;
align-items: center;
.act_img{
width: 38rpx;
height: 38rpx;
}
.goods_num{
min-width: 38rpx;
font-size: 28rpx;
font-weight: bold;
text-align: center;
padding: 0 7rpx;
}
}
}
}
}
//
.goods_sum{
position: absolute;
left: 0;
right:0;
bottom:0;
display: flex;
justify-content: space-between;
height: 128rpx;
background-color: #fff;
padding: 21rpx 30rpx;
.sum_title{
display: flex;
align-items: center;
font-size: 26rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
height: 78rpx;
color: #333333;
.price{
margin-left: 11rpx;
.price_unit{
font-size: 22rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #D73232;
}
.price{
font-size: 34rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #D73232;
margin-left: 3rpx;
}
}
}
.order_btn{
width: 320rpx;
height: 78rpx;
line-height: 78rpx;
background: #D73232;
border-radius: 20rpx;
font-size: 26rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
text-align: center;
}
}
}
</style>

@ -1,11 +1,11 @@
<template>
<view class="order_box">
<view class="order_title">
<p @click="handleTab(1)" class="tit" :class="active == '' ? 'actived' : ''">全部</p>
<p @click="handleTab(2)" class="tit" :class="active == 1 ? 'actived' : ''">待付款</p>
<p @click="handleTab(3)" class="tit" :class="active == 2 ? 'actived' : ''">待发货</p>
<p @click="handleTab(4)" class="tit" :class="active == 3 ? 'actived' : ''">待收货</p>
<p @click="handleTab(5)" class="tit" :class="active == 4 ? 'actived' : ''">已完成</p>
<p @click="handleTab('')" class="tit" :class="active == '' ? 'actived' : ''">全部</p>
<p @click="handleTab(1)" class="tit" :class="active == 1 ? 'actived' : ''">待付款</p>
<p @click="handleTab(2)" class="tit" :class="active == 2 ? 'actived' : ''">待发货</p>
<p @click="handleTab(3)" class="tit" :class="active == 3 ? 'actived' : ''">待收货</p>
<p @click="handleTab(4)" class="tit" :class="active == 4 ? 'actived' : ''">已完成</p>
</view>
<view class="order_content" v-for="(item,index) in orderData" :key="index">
<view class="order_item" @click="handleCheck(item)">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Loading…
Cancel
Save