Commit 4c9ddc05 by zhangcheng

调整页面bug

parent c0519cc6
......@@ -57,10 +57,14 @@
<text style="color:#000000;font-weight: bold;font-size: 28rpx;display: flex; margin-left: 30rpx; align-items: center;">{{totalPrice.toFixed(2)}}</text>
</view>
</view>
<view class="end-right" @click="saveReserve">
<view class="end-right" @click="saveReserve" v-if="userms">
付款
<!-- ({{totalNum}}) -->
</view>
<button v-if="!userms" class="end-right" style="border-radius: 0;" open-type="getPhoneNumber" @getphonenumber="saveReserve">
付款
<!-- ({{totalNum}}) -->
</button>
</view>
......@@ -70,6 +74,7 @@
<script>
import { $EventBus } from "../../utils/EventBus";
import Menu from '@/request/menu';
import User from '@/request/user';
export default{
data(){
return{
......@@ -111,46 +116,31 @@
this.showShopCar=false;
},
//跳转到结算
saveReserve() {
saveReserve(e) {
let Authorization = uni.getStorageSync('Authorization');
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter(v=>v.flag==true);
if(shopCarInfo && this.totalPrice>0 && this.totalNum>0){
// let orderDetails=[];
// shopCarInfo.forEach((item)=>{
// let res = {
// goodsId:item.goodsId,//商品id
// goodsName:item.name,//商品名称
// machineId:undefined,//点单屏机器ID
// num:item.num,//当前sku数量
// realAmount:item.skus[0].price*item.num,//实付金额
// specRuleDetail:JSON.stringify(item.skus[0].rules),//规格选项详情
// skuId:item.skus[0].skuId,//"sku ID"
// goodsCategory:item.categoryId//商品分类
// };
// orderDetails.push(res);
// });
// let DAta={
// amount:this.totalPrice,//商品总金额
// goodsNum:this.totalNum,//商品总数量
// shopId:this.$store.getters.shopInfo[0].id,//店铺
// machineId:undefined,//机器ID
// source:3,//小程序固定传3
// orderDetails:orderDetails
// }
// let res = Menu.saveReserve(DAta);
if(Authorization){
// 从购物车发起:payType=1;
// 立即购买:payType=2;
// 扫码进入:payType=3;
// 从购物车发起:buyType=1;
// 立即购买:buyType=2;
// 扫码进入:buyType=3;
uni.navigateTo({
url:`/menuSubPackage/pages/settlement/settlement?totalPrice=${this.totalPrice}&totalNum=${this.totalNum}&payType=1`
url:`/menuSubPackage/pages/settlement/settlement?totalPrice=${this.totalPrice}&totalNum=${this.totalNum}&buyType=1`
})
}else{
this.loginByPhoneNumber(e)
}
}
return;
},
// 付款前未登录发起授权
loginByPhoneNumber(e) {
if(e.detail.errMsg=='getPhoneNumber:ok'){
User.getPhoneNumber(e);
}else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){
uni.showToast({title:'已拒绝手机号授权',icon:'error'})
}
},
change(e){
console.log(e)
},
......@@ -191,12 +181,26 @@
uni.setStorageSync('shopCarInfo',this.goods);
},
add(item){
let s = 0;
this.goods.forEach(function(val) {
s += val.num;
}, 0);
if(s>=9){
uni.showToast({
title:'最多可一次购买9杯',
icon:'none'
});
return;
}
let num =item.num
item.num=num+1
uni.setStorageSync('shopCarInfo',this.goods);
}
},
computed:{
userms() {
return this.$store.getters.Authorization;
},
totalNum(){
let totalNum = 0;
this.goods.map(item => {
......@@ -392,11 +396,14 @@
}
}
&-right{
width: 30%;
line-height: 90rpx;
width: 169rpx;
font-size: 32rpx;
line-height: 92rpx;
background-color: #006ECF;
text-align: center;
color: #fff;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
}
}
</style>
<template>
<view>
详情页
<view class="spec-content">
<view class="uni-margin-wrap">
<swiper class="swiper" circular autoplay>
<swiper-item v-for="item in goodInfo.pics.introImages">
<view class="swiper-item">
<image class="swiper-spec-content-item-img" :src="item" mode="widthFix"></image>
</view>
</swiper-item>
</swiper>
</view>
<!-- <scroll-view scroll-x="true">
<view class="spec-banner-wrap" scroll-x="true">
<view class="spec-banner-wrap-item" v-for="item in goodInfo.pics.introImages">
<image class="spec-banner-wrap-item-img" :src="item" mode="widthFix"></image>
</view>
</view>
</scroll-view> -->
<view class="good spec-info-left">
<text class="good-name">{{goodInfo.name}}</text>
<view v-for="specItem in goodInfo.specs">
<text class="good-spec-name">{{specItem.specName}}</text>
<view class="good-spec-rule">
<view v-for="specItemRule in specItem.rules">
<text class="good-spec-rule-item">{{specItemRule.ruleName}}</text>
</view>
</view>
</view>
</view>
<view class="spec-detail">
<text class="spec-detail-title spec-info-left">商品详情</text>
<view class="spec-detail-img" v-for="item in goodInfo.pics.detailImages">
<image class=".spec-detail-img-item " :src="item" mode="widthFix"></image>
</view>
<view class="good-select-height">
</view>
</view>
<view class="good-select good-select-height">
<view class="good-select-price">
<text class="good-select-price-normal">¥100</text>
<text class="good-select-price-small">¥10</text>
</view>
<view class="good-select-cont">
<button class="good-select-btn" type="default" >立即购买</button>
<button class="good-select-btn" type="default" >加入购物袋</button>
</view>
</view>
</view>
</template>
......@@ -8,15 +59,305 @@
export default {
data() {
return {
title: 'Hello1',
imglist:[{img:"/static/logo.png"},{img:"/static/ggxz01.png"}],
goodInfo:{
"goodId": 100,
"name": "冰茶咖啡",
"price": 29.9,
"discount": 19.9,
"pics": {
"thumbnail": "http://baidu.com",
"introImages": [
"https://cdn.uviewui.com/uview/album/1.jpg",
"https://cdn.uviewui.com/uview/album/2.jpg",
"https://cdn.uviewui.com/uview/album/3.jpg"
],
"detailImages": [
"https://cdn.uviewui.com/uview/album/4.jpg",
"https://cdn.uviewui.com/uview/album/5.jpg",
"https://cdn.uviewui.com/uview/album/6.jpg"
]
},
"desc": "",
"remark": "",
"tags": [
"YYDS",
"杨幂同款"
],
"specs": [
{
"rules": [
{
"isDefault": "1",
"isRecommend": "0",
"price": "2",
"ruleId": "51",
"ruleName": "冰"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "1",
"ruleId": "52",
"ruleName": "热"
}
],
"specId": "44",
"specName": "温度"
},
{
"rules": [
{
"isDefault": "1",
"isRecommend": "0",
"price": "0",
"ruleId": "53",
"ruleName": "不加奶"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "1",
"ruleId": "54",
"ruleName": "正常奶"
}
],
"specId": "45",
"specName": "加奶"
},
{
"rules": [
{
"isDefault": "1",
"isRecommend": "0",
"price": "0",
"ruleId": "55",
"ruleName": "不加糖"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "1",
"ruleId": "56",
"ruleName": "半塘"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "2",
"ruleId": "57",
"ruleName": "标准糖"
}
],
"specId": "46",
"specName": "糖度"
}
],
"skus": [
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 2,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 2.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 4.00
}
]
}
]
}
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
<style lang="scss">
.uni-margin-wrap {
height: 444rpx;
width: 100%;
background: #ff00f0;
}
.swiper-spec-content {
height: 300rpx;
width: 100%;
}
.swiper-spec-content-item {
display: block;
height: 300rpx;
line-height: 300rpx;
text-align: center;
}
.swiper-spec-content-item-img {
height: 100%;
width: 100%;
}
.spec-content {
}
.spec-info-left{
padding:22rpx 34rpx;
}
.good {
display: block;
width: 100%;
text-align: left;
.good-name {
font-size: 32rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
line-height: 44rpx;
}
.good-spec-name {
margin-top:22rpx;
color: rgba(0, 0, 0, 1);
font-size: 28rpx;
text-align: left;
line-height: 40rpx;
font-weight: bold;
}
.good-spec-rule {
display: flex;
flex-direction: row;
justify-content: flex-start;
margin-left: 8rpx;
}
}
.good-spec-rule-item {
font-size: 24rpx;
margin-right: 10rpx;
}
.spec-detail {
width: 100%;
height: 100%;
}
.spec-detail-title{
font-weight: bold;
}
.spec-detail-img {
display: flex;
flex-direction: column;
margin-top: 0rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 0rpx;
padding: 0rpx;
justify-content: center;
align-items: center;
}
.spec-detail-img-item {
width: 100%;
height: 100%;
}
.good-select-height{
height:200rpx;
}
.good-select{
width: 90%;
position: fixed;
bottom: 0rpx;
text-align: center;
}
.good-select-price{
display: flex;
margin-top: 20rpx;
justify-content: flex-start;
align-items: flex-end;
}
.good-select-price-normal{
font-size: 36rpx;
color: rgba(235, 95, 23, 1);
}
.good-select-price-small{
font-size: 20rpx;
text-decoration:line-through;
}
.good-select-cont{
margin-top: 20rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.good-select-btn {
}
</style>
......@@ -11,7 +11,7 @@ import Menu from '@/request/menu'
export default {
data() {
return {
payType:0,//发起支付的页面标识//// 从购物车发起:payType=1;// 立即购买:payType=2;// 扫码进入:payType=3;
buyType:0,//发起支付的页面标识//// 从购物车发起:buyType=1;// 立即购买:buyType=2;// 扫码进入:buyType=3;
orderId:null,//扫码进来的orderId
viewData:{},//预支付数据订单数据
totalPrice:0,//总金额
......@@ -19,8 +19,8 @@ import Menu from '@/request/menu'
}
},
onLoad(options) {
if(options.payType){
this.payType = options.payType;
if(options.buyType){
this.buyType = options.buyType;
}
if(options.orderId){
this.orderId = options.orderId;
......@@ -33,12 +33,12 @@ import Menu from '@/request/menu'
}
},
onShow() {
if(this.orderId!=null && this.payType==3){
if(this.orderId!=null && this.buyType==3){
this.getOrderInfo()
}
},
onUnload(event){
if(this.orderId && this.payType==3){
if(this.orderId && this.buyType==3){
uni.switchTab({
url:'/pages/menu/menu'
});
......@@ -60,12 +60,12 @@ import Menu from '@/request/menu'
//结算组装数据发起订单
async saveReserve() {
// 组装购物车数据或者立即支付数据
let res = await Utils.AssemblyOrder(this.totalPrice,this.totalNum,this.payType);
let res = await Utils.AssemblyOrder(this.totalPrice,this.totalNum,this.buyType);
if(res){
// 发起订单
let orderInfo = await Menu.saveReserve(res);
if(orderInfo && orderInfo.data.code==200){
let payMent = await Menu.requestPayment(orderInfo.data.data);
let payMent = await Menu.requestPayment(orderInfo.data.data,res,this.buyType);
}
}
......
......@@ -46,6 +46,7 @@
"style" :
{
"navigationBarTitleText": "",
"navigationStyle":"custom",
"enablePullDownRefresh": false
}
......
......@@ -36,7 +36,7 @@
this.$store.commit('setAuthorization',Authorization);
if(this.id!=''){
uni.navigateTo({
url:`/menuSubPackage/pages/settlement/settlement?orderId=${this.id}&payType=3`
url:`/menuSubPackage/pages/settlement/settlement?orderId=${this.id}&buyType=3`
})
}else{
uni.reLaunch({
......
......@@ -177,16 +177,11 @@ import { $EventBus } from '@/utils/EventBus';
},
// 手机号授权登录
getPhoneNumber(e) {
// uni.exitMiniProgram({success: (res) => {}})
if(e.detail.errMsg=='getPhoneNumber:ok'){
User.getPhoneNumber(e,this.orderId);
}else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){
uni.showToast({title:'已拒绝手机号授权',icon:'error'})
}
// console.log(e,333)
if(e.detail.errMsg=='getPhoneNumber:ok'){
User.getPhoneNumber(e,this.orderId);
}else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){
uni.showToast({title:'已拒绝手机号授权',icon:'error'})
}
},
changeLocaltion() {
console.log(22345)
......
......@@ -38,30 +38,50 @@ export default {
})
},
// saveReserve 为业务接口
requestPayment(data) {
const {
errno,
errmsg,
res
} = data;
requestPayment(data, oldData, buyType) {
// res为调起微信支付所需参数
if (errno === '0') {
// 调起微信支付
uni.requestPayment({
provider: 'wxpay', // 服务提提供商微信支付
timeStamp: res.weChatPayData.timestamp, // 时间戳
nonceStr: res.weChatPayData.noncestr, // 随机字符串
package: res.weChatPayData.package,
signType: res.weChatPayData.signtype || 'MD5', // 签名算法
paySign: res.weChatPayData.sign, // 签名
timeStamp: data.timeStamp, // 时间戳
nonceStr: data.nonceStr, // 随机字符串
package: data.package,
signType: data.signType || 'MD5', // 签名算法
paySign: data.paySign, // 签名
success: function (res) {
console.log('支付成功', res);
if (res.errMsg == 'requestPayment:ok'){
uni.showToast({
title: '支付成功'
});
if (buyType==1){
let shopCarInfo = uni.getStorageSync('shopCarInfo');
for (let i = 0; i < oldData.length; i++){
let element = oldData[i];
for (let y = 0; y < shopCarInfo.length; y++) {
let item = shopCarInfo[y];
if (item.skus[0].skuId === element.skus[0].skuId) {
shopCarInfo.splice(index, 1);
}
}
}
// 删除购物车数据后重新放回购物车
uni.setStorageSync('shopCarInfo', shopCarInfo);
$EventBus.$emit('updateCar');
uni.navigateTo({
url:'/page/menu/menu'
})
}
}
// 业务逻辑。。。
},
fail: function (err) {
console.log('支付失败', err);
uni.showToast({
title:'支付失败',
icon:'error'
})
}
});
}
}
}
\ No newline at end of file
......@@ -40,6 +40,17 @@ export default{
// 加入购物车数据
getallNum(Obj){
let shopCarInfo = uni.getStorageSync('shopCarInfo');
let s = 0;
shopCarInfo.forEach(function (val) {
s += val.num;
}, 0);
if (s >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none'
});
return;
}
console.log(shopCarInfo,'oooooo')
if (shopCarInfo){
let currentGoods = shopCarInfo.find(v => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment