Commit beb84ae0 authored by 黄媛媛's avatar 黄媛媛

111

parent b9439f0f
......@@ -103,7 +103,6 @@ export default {
methods: {
// 购物车
showSkuHandler(g) {
console.log('g', g);
this.sku = g;
this.showSku = true;
},
......
......@@ -94,7 +94,7 @@ export default {
this.active=i
},
clickHandler(item) {
uni.navigateTo({ url: '/pages/goods/goods?GoodsId='+item.Id });
uni.navigateTo({ url: '/pages/goods/goods?GoodsId='+item.id });
},
init() {
this.isover = false;
......
<template>
<div class="catstyle4" style="height: 100%;">
<view class="catstyle4" style="height: 100%;">
<div class="left-slider">
<sidebar
:active="tid"
......@@ -57,7 +57,7 @@
</div>
<div class="sell">{{ cx.sales }}</div>
</div>
<div class="right">
<div @click.stop="showSkuHandler(cx)" class="right">
<!-- todo 点击加入购物车-->
<u-icon name="cart-circle-o" size="44" :color="mainColor" />
</div>
......@@ -67,16 +67,16 @@
<u-divider v-if="isover" :margin-top="20" :margin-bottom="20">没有更多商品了</u-divider>
</scroll-view>
</div>
</div>
<good-sku v-if="showSku" :option-type="2" borderRadius="20" v-model="showSku" :good="sku"></good-sku>
</view>
</template>
<script>
import goodSku from '../goods/goodsku';
import sidebar from "../sidebar/index";
export default {
props: ["d", "h"],
components: {
sidebar,
},
data() {
return {
mainColor: "",
......@@ -98,8 +98,13 @@ export default {
OrderBy:1,
UserId:0,
},
sku: {},
showSku: false
};
},
components: {
sidebar,goodSku
},
created() {
this.mainColor = this.$uiConfig.mainColor;
this.activeStyle = `background:${this.mainColor};`;
......@@ -108,6 +113,11 @@ export default {
this.init();
},
methods: {
// 购物车
showSkuHandler(g) {
this.sku = g;
this.showSku = true;
},
changeHandler(i) {
this.msg.CategoryIds= this.d[i].Id+'';
this.msg.page = 1;
......@@ -116,7 +126,7 @@ export default {
this.init();
},
clickHandler(item) {
uni.navigateTo({ url: '/pages/goods/goods?GoodsId='+item.Id });
uni.navigateTo({ url: '/pages/goods/goods?GoodsId='+item.id });
},
init() {
this.isover = false;
......
......@@ -33,7 +33,7 @@
<image
v-if="x.IconPath && x.IconPath.length > 0"
mode="aspectFit"
:src="getIconLink(c.IconPath)"
:src="getIconLink(x.IconPath)"
style="width: 100%; height: 100%;"
/>
</div>
......
......@@ -56,7 +56,7 @@
<view class="price" :style="{ color: mainColor }">{{ cx.price_content }}</view>
<view class="sell">{{ cx.sales }}</view>
</view>
<view class="right">
<view @click.stop="showSkuHandler(cx)" class="right">
<u-icon name="cart-circle-o" size="44" :color="mainColor" />
</view>
</view>
......@@ -71,11 +71,13 @@
</scroll-view>
</view>
</view>
<good-sku v-if="showSku" :option-type="2" borderRadius="20" v-model="showSku" :good="sku"></good-sku>
</view>
</template>
<script>
import sidebar from "../sidebar/index";
import goodSku from '../goods/goodsku';
export default {
props: ["d", "h"],
data() {
......@@ -103,10 +105,12 @@ export default {
CategoryIdsList:[],
CategoryIds1:'',
CategoryIds2:'',
sku: {},
showSku: false
};
},
components: {
sidebar
sidebar,goodSku
},
created() {
this.mainColor = this.$uiConfig.mainColor;
......@@ -123,6 +127,11 @@ export default {
this.init();
},
methods: {
// 购物车
showSkuHandler(g) {
this.sku = g;
this.showSku = true;
},
changeHandler(i) {
this.active=i;
this.CategoryIds1=this.d[i].Id;
......@@ -142,7 +151,7 @@ export default {
this.init();
},
clickHandler(item) {
uni.navigateTo({ url: '/pages/goods/goods?GoodsId='+item.Id });
uni.navigateTo({ url: '/pages/goods/goods?GoodsId='+item.id });
},
init() {
this.CategoryIdsList=[];
......
......@@ -101,13 +101,13 @@ export default {
<style>
.coupon {
min-height: 70vh;
max-height: 70vh;
background: #f5f5f5;
padding-bottom: 50px;
text-align: left !important;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
overflow: hidden;
overflow: scroll;
}
.coupon .title {
font-size: 22px;
......
......@@ -138,6 +138,7 @@ export default {
};
},
mounted() {
console.log("good",this.good)
this.request2(
{
url: '/api/AppletGoods/GetAppletGoodsInfo',
......
......@@ -26,14 +26,14 @@
<image :src="y.cover_pic" mode="aspectFill" class="image" />
<view class="goodinfo">
<view class="name">{{ y.name }}</view>
<view class="attr">已选择 {{ y.attrStr }}</view>
<view class="attr">已选择
<span v-for="(item,index) in y.attr_list" :key="index">{{ item.attr_group_name}}:{{ item.attr_name}}</span>
</view>
<view class="price">
<view class="left" :style="{ color: mc }">
<text class="small"></text>
<text>{{ y.goods_attr.price.split(".")[0] }}</text>
<text class="small"
>.{{ y.goods_attr.price.split(".")[1] || "00" }}</text
>
<text>{{ y.goods_attr.price}}</text>
<!-- <text class="small">.{{ y.goods_attr.price.split(".")[1] || "00" }}</text> -->
</view>
<view class="right">x{{ y.num }}</view>
</view>
......
<template>
<view>
<u-popup
close-icon-color="red"
v-model="show"
mode="center"
:mask-close-able="false"
length="auto"
:closeable="true"
close-icon="close"
:border-radius="20"
:z-index="9999"
>
<view style="background:#fff;width:550rpx;padding:40rpx;border-radius:20px">
<u-icon @click="closePay" name="close" style="float:right;font-size:40rpx"></u-icon>
<p style="text-align: center;font-size: 26rpx;">支付方式</p>
<p style="font-size: 36rpx;font-weight: 700;text-align: center;margin:30px 0">支付金额{{ payInfo.total_price }}</p>
<p>
<img style="width:50rpx;height:50rpx;margin-right:10px" src="../../static/wx.png" alt="" />
<span style="position:relative;top:-7px">微信支付</span>
</p>
<view style="margin-top:30px"><u-button @click="Pay" type="error" shape="circle">支付</u-button></view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
props: ['payInfo'],
data() {
return {
show: true,
orderInfo: {}
};
},
created() {
this.getDataInfo();
},
methods: {
closePay() {
this.$emit('closePay');
},
getDataInfo() {
let msg = {
OpenId: 'ow_7I5XC1-RGwwk8QANBmWKYKmOc',
OrderId: '1',
OrderPayType: 1,
GoodsName: '测试商品名称'
};
this.request2(
{
url: '/api/WeChatPay/GetPayInfo',
data: msg
},
res => {
console.log('res', res);
if (res.resultCode == 1) {
this.orderInfo = JSON.parse(res.data);
}
uni.hideNavigationBarLoading();
}
);
},
Pay() {
let orderInfo = this.orderInfo;
uni.requestPayment({
provider: 'wxpay',
timeStamp: this.orderInfo.timeStamp,
nonceStr: this.orderInfo.nonceStr,
package: this.orderInfo.package,
signType: this.orderInfo.signType,
paySign: this.orderInfo.sign,
success: function(res) {
console.log('success', res);
uni.navigateTo({
url: '/pages/order-submit/pay-success'
});
},
fail: function(err) {
console.log('fail:', err);
}
});
}
}
};
</script>
<style></style>
......@@ -6,9 +6,9 @@
:enable-flex="true"
:style="{ height: '100%' }"
>
<view v-for="(item, index) in list" :key="index" class="addresbox">
<view v-for="(item, index) in list" :key="index" class="addresbox" @click="chosenHandler(item)">
<view class="addresclo">
<Text >收件人:{{item.Name}}</Text>
<Text>收件人:{{item.Name}}</Text>
<Text>{{item.Mobile}}</Text>
</view>
<Text style='width: 100%;'>收货地址:{{item.DistrictAddress}}{{item.Address}}</Text>
......@@ -24,14 +24,14 @@
<view style="display: flex;flex-direction: row;align-items: center;">
<view
style="display: flex;flex-direction: row;align-items: center;"
@click="btn_edit(item)"
@click.stop="btn_edit(item)"
>
<u-icon name="edit" color="#c8c9cc" size="40"></u-icon>
<Text style="color:#c8c9cc;">编辑</Text>
</view>
<view
style="display: flex;flex-direction: row;align-items: center;margin: 0 30rpx"
@click="btn_delete(item)"
@click.stop="btn_delete(item)"
>
<u-icon name="delete" color="#c8c9cc" size="40"></u-icon>
<Text style="color:#c8c9cc;">删除</Text>
......@@ -84,6 +84,11 @@ export default {
IsDefault:0,
Mobile:'',
},
source: "",
defaultId: 0,
currentAddress: {},
list: [],
mc:"",
};
},
......@@ -110,7 +115,7 @@ export default {
title: this.pageTitle,
});
},
onLoad() {
onLoad(option) {
this.u = wx.getStorageSync("userinfo");
if (!this.u) {
this.u = {
......@@ -118,10 +123,24 @@ export default {
avatarUrl: ""
};
this.showAuth = true;
}
if (option && option.form) {
(this.source = option.form), (this.defaultId = option.id);
}
this.init();
},
methods: {
chosenHandler(item){
console.log("chosenHandler",item)
let pages = getCurrentPages()
let prevPage = pages[ pages.length - 2 ]
prevPage.$vm.formData.address_id = item.Id;
prevPage.$vm.formdata.AddressId = item.Id;
prevPage.$vm.adressInfo=item;
uni.navigateBack({
delta: 1
})
},
init() {
this.loading = false;
uni.showNavigationBarLoading();
......
......@@ -5,28 +5,28 @@
<view class="default">
<u-icon name="checked" size="44" :color="mc"></u-icon>
</view>
<view class="address" @click="chosenHandler(currentAddress.id)">
<view class="address" @click="chosenHandler(currentAddress)">
<view class="base">
<text class="name">{{currentAddress.name}}</text>
<text class="phone">{{currentAddress.mobile}}</text>
<text class="name">{{currentAddress.Name}}</text>
<text class="phone">{{currentAddress.Mobile}}</text>
</view>
<view class="details">
{{currentAddress.address}}
{{currentAddress.Address}}
</view>
</view>
<view class="edit">
<view @click.stop="btn_edit(currentAddress)" class="edit">
<u-icon name="edit" size="44" color="#444"></u-icon>
</view>
</view>
<view class="item" v-for="(x, i) in list" :key="i">
<view class="address">
<view class="base" @click="chosenHandler(x.id)">
<text class="name">{{x.name}}</text>
<text class="phone">{{x.mobile}}</text>
<view class="base" @click="chosenHandler(x)">
<text class="name">{{x.Name}}</text>
<text class="phone">{{x.Mobile}}</text>
</view>
<view class="details">{{x.address}}</view>
<view class="details">{{x.Address}}</view>
</view>
<view class="edit">
<view @click.stop="btn_edit(x)" class="edit">
<u-icon name="edit" size="44" color="#444"></u-icon>
</view>
</view>
......@@ -59,11 +59,17 @@ export default {
defaultId: 0,
currentAddress: {},
list: [],
mc:""
mc:"",
msg:{
Name:'',
IsDefault:0,
Mobile:'',
},
};
},
onLoad(option) {
if (option.form) {
console.log("option",option)
if (option && option.form) {
(this.source = option.form), (this.defaultId = option.id);
}
this.mc = this.$uiConfig.mainColor;
......@@ -71,39 +77,48 @@ export default {
this.init();
},
methods: {
chosenHandler(id){
btn_edit(item) {
console.log("item",item)
uni.navigateTo({
url: "/pages/address/AddAddress?AddressId="+item.Id
});
},
chosenHandler(item){
let pages = getCurrentPages()
let prevPage = pages[ pages.length - 2 ]
prevPage.$vm.formData.address_id = id
prevPage.$vm.formData.address_id = item.Id;
prevPage.$vm.formdata.AddressId = item.Id;
prevPage.$vm.adressInfo=item;
uni.navigateBack({
delta: 1
})
},
newAddressHandler(){
console.log("hhhh")
uni.navigateTo({
url: '/pages/address/addAddress'
url: '/pages/address/AddAddress'
});
},
init() {
console.log("1111")
this.loading = false;
let h=this.apiheader()
this.request(
this.request2(
{
url: "",
header: h,
data: {
r: "api/user/address",
},
url: '/api/AppletUser/GetUserShippingAddressList',
data: this.msg
},
(res) => {
res => {
uni.hideNavigationBarLoading();
console.log("res",res)
if(res.resultCode==1){
this.isloading = false;
this.list = res.data.list;
this.list = res.data;
let index = -1;
this.list.forEach((x, i) => {
x.mobile = x.mobile.substr(0, 3) + "****" + x.mobile.substr(7);
if (x.id == this.defaultId) {
x.MobileNew = x.Mobile;
x.Mobile = x.Mobile.substr(0, 3) + "****" + x.Mobile.substr(7);
if (x.Id == this.defaultId) {
this.currentAddress = x;
index = i;
}
......@@ -112,7 +127,35 @@ export default {
this.list.splice(index, 1);
}
}
}
);
// let h=this.apiheader()
// this.request(
// {
// url: "",
// header: h,
// data: {
// r: "api/user/address",
// },
// },
// (res) => {
// uni.hideNavigationBarLoading();
// this.isloading = false;
// this.list = res.data.list;
// let index = -1;
// this.list.forEach((x, i) => {
// x.mobile = x.mobile.substr(0, 3) + "****" + x.mobile.substr(7);
// if (x.id == this.defaultId) {
// this.currentAddress = x;
// index = i;
// }
// });
// if (index != -1) {
// this.list.splice(index, 1);
// }
// }
// );
},
},
};
......
......@@ -10,21 +10,11 @@
"
>
<Text class="grid-text">商品库存有限,请尽快下单哦</Text>
<Text @click="edit" v-if="editType == false" class="grid-text_r"
>编辑</Text
>
<Text @click="edit" v-if="editType == true" class="grid-text_r"
>完成</Text
>
<Text @click="edit" v-if="editType == false" class="grid-text_r">编辑</Text>
<Text @click="edit" v-if="editType == true" class="grid-text_r">完成</Text>
</view>
<view
style="width: 100%; height: 30rpx; background: #f7f7f7; margin: 20rpx 0;"
></view>
<u-empty
v-if="list.length == 0"
text="购物车还是空的哦"
mode="car"
></u-empty>
<view style="width: 100%; height: 30rpx; background: #f7f7f7; margin: 20rpx 0;"></view>
<u-empty v-if="list.length == 0" text="购物车还是空的哦" mode="car"></u-empty>
<view
v-if="list.length > 0"
......@@ -35,19 +25,9 @@
padding-top: 10px;
"
>
<scroll-view
:scroll-y="true"
:enable-back-to-top="true"
:enable-flex="true"
:style="{ height: '100%' }"
>
<scroll-view :scroll-y="true" :enable-back-to-top="true" :enable-flex="true" :style="{ height: '100%' }">
<template v-if="list.length > 0">
<view
class="cartList"
:style="{ 'margin-bottom': listbottom }"
v-for="(c, i) in list"
:key="i"
>
<view class="cartList" :style="{ 'margin-bottom': listbottom }" v-for="(c, i) in list" :key="i">
<view
style="
padding: 0 12px 12px 12px;
......@@ -56,45 +36,22 @@
"
>
<u-checkbox-group @change="mch_SelectAll(c.checked, i)">
<u-checkbox
v-model="c.checked"
shape="circle"
:active-color="mc"
>{{ c.name }}</u-checkbox
>
<u-checkbox v-model="c.checked" shape="circle" :active-color="mc">{{ c.MallName }}</u-checkbox>
</u-checkbox-group>
</view>
<view
class="cartList_item"
v-for="(item, index) in c.goods_list"
:key="index"
:name="item.name"
>
<view style="width: 40px;text-align: center;" v-if="item.new_status == 0 || editType == true">
<u-checkbox-group
@change="
clickcheckbox(item.checked, item.attrs.price, index, i)
"
>
<u-checkbox
v-model="item.checked"
shape="circle"
:active-color="mc"
></u-checkbox>
<view class="cartList_item" v-for="(item, index) in c.GoodsList" :key="index" :name="item.GoodsName">
<view style="width: 40px;text-align: center;" v-if="item.GoodsStatus == 1 || editType == true">
<u-checkbox-group @change="clickcheckbox(item.checked, item.Price, index, i)">
<u-checkbox v-model="item.checked" shape="circle" :active-color="mc"></u-checkbox>
</u-checkbox-group>
</view>
<view class="invalid" :style="{ background: mc }" v-if="item.new_status != 0 && editType == false">
<Text
style="color: #fff; width: 22px;font-size: 20rpx;"
>失效</Text
>
<view class="invalid" :style="{ background: mc }" v-if="item.GoodsStatus != 1 && editType == false">
<Text style="color: #fff; width: 22px;font-size: 20rpx;">失效</Text>
</view>
<image
:src="
item.attrs.pic_url ? item.attrs.pic_url : item.goods.cover_pic
"
:src="item.CoverImage"
mode="aspectFill"
style="
width: 150rpx;
......@@ -102,7 +59,7 @@
margin-left: 30rpx;
border-radius: 5px;
"
@click="clickHandler(item.goods_id)"
@click="clickHandler(item.GoodsId)"
/>
<view
style="
......@@ -122,8 +79,9 @@
white-space: nowrap;
text-overflow: ellipsis;
"
>{{ item.goods.name }}</Text
>
{{ item.GoodsName}}
</Text>
<view
style="
width: 440rpx;
......@@ -132,15 +90,16 @@
text-overflow: ellipsis;
"
>
<view v-for="(attr, inde2x) in item.attrs.attr" :key="inde2x">
<view v-for="(attr, inde2x) in item.SpecificationList" :key="inde2x">
<Text
style="
color: #a0a09d;
font-size: 24rpx;
margin-right: 5rpx;
"
>{{ attr.attr_group_name }}:{{ attr.attr_name }}</Text
>
{{ attr}}
</Text>
</view>
</view>
<view
......@@ -151,18 +110,18 @@
justify-content: space-between;
"
>
<Text style="font-size: 30rpx;" :style="{ color: mc }"
>¥<Text style="40rpx">{{ item.attrs.price }}</Text></Text
>
<Text style="font-size: 30rpx;" :style="{ color: mc }">
<Text style="40rpx">{{ item.Price }}</Text>
</Text>
<u-number-box
v-model="item.num"
v-model="item.Number"
:min="1"
:max="item.goods.goods_stock"
@change="valChange(i,index, item.num,item.attrs.price,$event)"
:max="item.InventoryNum"
@change="valChange(i, index, item.Number, item.Price, $event)"
></u-number-box>
</view>
<Text v-if="item.new_status != 0 && editType == false" style='font-size: 20rpx;color:#a0a09d ;'>失效原因:商品下架或者库存不足</Text>
<Text v-if="item.GoodsStatus != 1 && editType == false" style="font-size: 20rpx;color:#a0a09d ;">失效原因:商品下架或者库存不足</Text>
</view>
</view>
</view>
......@@ -173,16 +132,9 @@
<view class="box_bottom">
<div style="margin-left: 30rpx;">
<u-checkbox-group @change="SelectAll">
<u-checkbox v-model="allchecked" shape="circle" :active-color="mc"
>全选</u-checkbox
>
<u-checkbox v-model="allchecked" shape="circle" :active-color="mc">全选</u-checkbox>
</u-checkbox-group>
<Text
style="font-size: 30rpx;"
:style="{ color: mc }"
v-if="editType == false"
>¥{{ TotalPrice }}</Text
>
<Text style="font-size: 30rpx;" :style="{ color: mc }" v-if="editType == false">¥{{ TotalPrice }}</Text>
</div>
<div class="bottom_btn" v-if="!editType">
<u-button
......@@ -194,9 +146,10 @@
backgroundColor: mc,
height: '80rpx',
color: '#FFF',
fontSize: '14px',
fontSize: '14px'
}"
>去结算({{ checkCount }})
>
去结算({{ checkCount }})
</u-button>
</div>
<u-button
......@@ -210,9 +163,10 @@
height: '80rpx',
color: '#FFF',
fontSize: '14px',
marginRight: '12px',
marginRight: '12px'
}"
>删除
>
删除
</u-button>
</view>
......@@ -220,12 +174,12 @@
</div>
</template>
<script>
import tabbars from "@/components/tabbar/index";
import tabbars from '@/components/tabbar/index';
export default {
data() {
return {
isloading: true,
pageTitle: "购物车",
pageTitle: '购物车',
navHeight: 0,
contentHeight: 0,
cstyle: {},
......@@ -238,74 +192,74 @@ export default {
list: [],
cart_id_list: [],
mc: "",
secondary: "",
mc: '',
secondary: '',
checkCount: 0,
msg: {
pageIndex: 1,
pageSize: 50,
Name: ''
}
};
},
created() {},
components: {
tabbars,
tabbars
},
onLoad() {
this.navHeight = this.$navHeight - 2;
this.mc = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
this.cstyle = uni.getStorageSync("basedata")
? uni.getStorageSync("basedata").cat_style
: [];
this.cstyle = uni.getStorageSync('basedata') ? uni.getStorageSync('basedata').cat_style : [];
if (this.cstyle.cat_style == "4") {
if (this.cstyle.cat_style == '4') {
}
},
mounted() {
let currentPages = getCurrentPages();
let c = this.$uiConfig.is_bang ? 80 : 52;
this.bottommargin = c - 2 + "px";
this.listbottom = c + 44 + "px";
this.contentHeight = this.$utils.calcContentHeight(c - 42) + "px";
let u = "/" + currentPages[currentPages.length - 1].route;
let pages = wx.getStorageSync("basedata")
? wx.getStorageSync("basedata").bar_title
: [];
pages.forEach((x) => {
this.bottommargin = c - 2 + 'px';
this.listbottom = c + 44 + 'px';
this.contentHeight = this.$utils.calcContentHeight(c - 42) + 'px';
let u = '/' + currentPages[currentPages.length - 1].route;
let pages = wx.getStorageSync('basedata') ? wx.getStorageSync('basedata').bar_title : [];
pages.forEach(x => {
if (x.value == u) {
this.pageTitle = x.new_name ? x.new_name : x.name;
}
});
uni.setNavigationBarTitle({
title: this.pageTitle,
title: this.pageTitle
});
this.init();
},
methods: {
goHome() {
uni.redirectTo({
url: "/pages/index/main",
url: '/pages/index/main'
});
},
init() {
uni.showNavigationBarLoading();
let h = this.apiheader();
this.request(
this.request2(
{
url: "",
header: h,
data: {
r: "api/cart/list",
},
url: '/api/AppletOrder/GetGoodsShoppingCartPageList',
data: this.msg
},
(res) => {
res => {
this.loading = false;
console.log('resggg', res);
if (res.resultCode == 1) {
uni.hideNavigationBarLoading();
this.isloading = false;
if (res.data.list.length > 0) {
let list = res.data.list;
list.forEach((x) => {
if (res.data.pageData.length > 0) {
let list = res.data.pageData;
list.forEach(x => {
x.checked = false;
x.goods_list.forEach((j) => {
x.GoodsList.forEach(j => {
j.checked = false;
j.id=j.Id;
});
});
this.list = list;
......@@ -313,15 +267,45 @@ export default {
this.list = [];
}
}
uni.hideNavigationBarLoading();
}
);
// this.request(
// {
// url: '',
// header: h,
// data: {
// r: 'api/cart/list'
// }
// },
// res => {
// uni.hideNavigationBarLoading();
// this.isloading = false;
// if (res.data.list.length > 0) {
// let list = res.data.list;
// list.forEach(x => {
// x.checked = false;
// x.goods_list.forEach(j => {
// j.checked = false;
// });
// });
// this.list = list;
// } else {
// this.list = [];
// }
// }
// );
},
clickcheckbox(checked, price, index, i) {
// (item.checked, item.Price, index, i)
if (checked == true) {
this.checkCount += 1;
this.TotalPrice += parseFloat((price*this.list[i].goods_list[index].num).toFixed(2)) ;
this.TotalPrice += parseFloat((price * this.list[i].GoodsList[index].Number).toFixed(2));
let goods_list_all = true; //判断该商场是否全选
this.list[i].goods_list.forEach((x) => {
this.list[i].GoodsList.forEach(x => {
if (this.editType == false) {
//编辑的时候不判断
if (x.checked == false && x.new_status == 0) {
......@@ -337,7 +321,7 @@ export default {
this.list[i].checked = true;
}
let list_all = true; //判断所有商场是否全选
this.list.forEach((x) => {
this.list.forEach(x => {
if (x.checked == false) {
list_all = false;
}
......@@ -348,16 +332,16 @@ export default {
if (this.editType == true) {
let obj = {
mch_id: 0,
id: this.list[i].goods_list[index].id,
id: this.list[i].GoodsList[index].id
};
this.cart_id_list.push(obj);
}
} else {
this.TotalPrice -= parseFloat((price*this.list[i].goods_list[index].num).toFixed(2)) ;
this.TotalPrice -= parseFloat((price * this.list[i].GoodsList[index].Number).toFixed(2));
this.checkCount -= 1;
this.allchecked = false;
let goods_list_all = true; //判断该商场是否全选
this.list[i].goods_list.forEach((x) => {
this.list[i].GoodsList.forEach(x => {
if (x.checked == false) {
goods_list_all = false;
}
......@@ -367,36 +351,35 @@ export default {
}
if (this.editType == true) {
this.cart_id_list.forEach((x, j) => {
if (x.id == this.list[i].goods_list[index].id) {
if (x.id == this.list[i].GoodsList[index].id) {
this.cart_id_list.splice(j, 1);
}
});
}
}
this.TotalPrice = parseFloat((this.TotalPrice).toFixed(2) )
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
mch_SelectAll(checked, i) {
if (checked == true) {
let add_cartlist = [];
let new_statusnum = 0;
this.list[i].goods_list.forEach((x) => {
if (x.new_status == 0) {
if(x.checked ==false){
this.TotalPrice += parseFloat((x.attrs.price* x.num).toFixed(2));
this.list[i].GoodsList.forEach(x => {
if (x.GoodsStatus == 1) {
if (x.checked == false) {
this.TotalPrice += parseFloat((x.Price * x.Number).toFixed(2));
x.checked = true;
new_statusnum++;
}
}
//编辑时候的商城全选
if (this.editType == true) {
if (this.cart_id_list.length > 0) {
this.cart_id_list.forEach((z) => {
this.cart_id_list.forEach(z => {
if (x.id != z.id) {
let obj = {
mch_id: 0,
id: x.id,
id: x.id
};
add_cartlist.push(obj);
}
......@@ -404,7 +387,7 @@ export default {
} else {
let obj = {
mch_id: 0,
id: x.id,
id: x.id
};
add_cartlist.push(obj);
}
......@@ -412,7 +395,7 @@ export default {
});
this.cart_id_list = this.cart_id_list.concat(add_cartlist);
let list_all = true; //判断所有商场是否全选
this.list.forEach((x) => {
this.list.forEach(x => {
if (x.checked == false) {
list_all = false;
}
......@@ -423,10 +406,10 @@ export default {
this.checkCount += new_statusnum;
} else {
let new_statusnum = 0;
this.list[i].goods_list.forEach((x) => {
if (x.new_status == 0) {
this.list[i].GoodsList.forEach(x => {
if (x.GoodsStatus == 1) {
x.checked = false;
this.TotalPrice -= parseFloat((x.attrs.price* x.num).toFixed(2));
this.TotalPrice -= parseFloat((x.Price * x.Number).toFixed(2));
new_statusnum++;
}
......@@ -440,7 +423,7 @@ export default {
this.allchecked = false;
this.checkCount -= new_statusnum;
}
this.TotalPrice = parseFloat((this.TotalPrice).toFixed(2) )
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
SelectAll() {
let list = this.list;
......@@ -448,20 +431,20 @@ export default {
this.checkCount = 0;
this.TotalPrice = 0;
this.cart_id_list = [];
list.forEach((x) => {
list.forEach(x => {
x.checked = true;
x.goods_list.forEach((j) => {
if (j.new_status == 0) {
x.GoodsList.forEach(j => {
if (j.GoodsStatus == 1) {
j.checked = true;
this.checkCount++;
this.TotalPrice +=parseFloat((j.attrs.price* j.num).toFixed(2)) ;
this.TotalPrice += parseFloat((j.Price * j.Number).toFixed(2));
}
//编辑的时候
if (this.editType == true) {
this.cart_id_list.push({
mch_id: 0,
id: j.id,
id: j.id
});
}
});
......@@ -470,33 +453,31 @@ export default {
this.checkCount = 0;
this.TotalPrice = 0;
this.cart_id_list = [];
list.forEach((x) => {
list.forEach(x => {
x.checked = false;
x.goods_list.forEach((j) => {
x.GoodsList.forEach(j => {
j.checked = false;
});
});
}
this.TotalPrice = parseFloat((this.TotalPrice).toFixed(2) )
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
valChange(i, index, num, p, e){
valChange(i, index, Number, p, e) {
// (i, index, item.Number, item.Price, $event)
let value = parseFloat(e.value);
let price = parseFloat(p);
// console.log(i, index, num, price, value)
if(num > value){
this.list[i].goods_list[index].num = value;
if(this.list[i].goods_list[index].checked == true){
this.TotalPrice -= parseFloat((price*(num-value)).toFixed(2)) ;
if (Number > value) {
this.list[i].GoodsList[index].Number = value;
if (this.list[i].GoodsList[index].checked == true) {
this.TotalPrice -= parseFloat((price * (Number - value)).toFixed(2));
}
}else if(value>num){
this.list[i].goods_list[index].num = value;
if(this.list[i].goods_list[index].checked == true){
this.TotalPrice +=parseFloat((price*(value- num)).toFixed(2)) ;
} else if (value > Number) {
this.list[i].GoodsList[index].Number = value;
if (this.list[i].GoodsList[index].checked == true) {
this.TotalPrice += parseFloat((price * (value - Number)).toFixed(2));
}
}
this.TotalPrice = parseFloat((this.TotalPrice).toFixed(2) )
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
edit() {
......@@ -506,9 +487,9 @@ export default {
this.checkCount = 0;
this.cart_id_list = [];
let list = this.list;
list.forEach((x) => {
list.forEach(x => {
x.checked = false;
x.goods_list.forEach((j) => {
x.GoodsList.forEach(j => {
j.checked = false;
});
});
......@@ -516,94 +497,105 @@ export default {
delete_btn() {
if (this.cart_id_list.length > 0) {
uni.showNavigationBarLoading();
let h = this.apiheader();
h["content-type"] = "application/x-www-form-urlencoded";
this.request(
let arr=[];
this.cart_id_list.forEach(item=>{
arr.push(item.id);
})
this.request2(
{
url: "",
method: "POST",
header: h,
data: {
r: "api/cart/delete",
cart_id_list: JSON.stringify(this.cart_id_list),
url: '/api/AppletOrder/DelGoodsShoppingCartInfo',
data: {ShoppingCartIdList:arr}
},
},
(res) => {
res => {
if(res.resultCode==1){
this.init();
this.TotalPrice = 0;
this.editType = false;
this.allchecked = false;
this.checkCount = 0;
}
uni.hideNavigationBarLoading();
}
);
// this.request(
// {
// url: '',
// method: 'POST',
// header: h,
// data: {
// r: 'api/cart/delete',
// cart_id_list: JSON.stringify(this.cart_id_list)
// }
// },
// res => {
// this.init();
// this.TotalPrice = 0;
// this.editType = false;
// this.allchecked = false;
// this.checkCount = 0;
// uni.hideNavigationBarLoading();
// }
// );
} else {
uni.showToast({
title: "请选择需要删除的商品",
position: "bottom",
icon: "none",
duration: 2000,
title: '请选择需要删除的商品',
position: 'bottom',
icon: 'none',
duration: 2000
});
}
},
settlement() {
let ShoppingCartIdList=[];
if (this.checkCount > 0) {
let forms = {
list: [],
address_id: 0,
};
this.list.forEach((y) => {
let forms = {};
this.list.forEach(y => {
let good = {
mch_id: y.mch_id,
goods_list: [],
distance: 0,
remark: "",
order_form: [],
use_integral: 0,
user_coupon_id: 0,
// MallId: y.MallId,
DetailList: [],
Use_Integral: 0,
User_Coupon_Id: 0,
DeliveryMethod:0,
AddressId:0,
};
y.goods_list.forEach((x) => {
y.GoodsList.forEach(x => {
if (x.checked) {
console.log("x",x)
ShoppingCartIdList.push(x.Id)
let g = {
id: x.goods_id,
num: x.num,
cart_id: x.id,
goods_attr_id: x.attr_id,
attr: [],
GoodsId: x.GoodsId,
Number: x.Number,
SpecificationSort: x.SpecificationSort,
};
x.attrs.attr.forEach((x) => {
g.attr.push({
attr_id: x.attr_id,
attr_group_id: x.attr_group_id,
});
});
good.goods_list.push(g);
good.DetailList.push(g);
}
});
forms.list.push(good);
forms=good;
console.log("forms",forms)
});
uni.navigateTo({
url:
"/pages/order-submit/order-submit?formData=" +
encodeURIComponent(JSON.stringify(forms)),
url: '/pages/order-submit/order-submit?formData=' + encodeURIComponent(JSON.stringify(forms))+'&IsFormShoppingCart=1&ShoppingCartIdList='+JSON.stringify(ShoppingCartIdList)
});
} else {
uni.showToast({
title: "请选择购买商品",
position: "bottom",
icon: "none",
duration: 2000,
title: '请选择购买商品',
position: 'bottom',
icon: 'none',
duration: 2000
});
}
},
clickHandler(id) {
uni.navigateTo({
url: '/pages/goods/goods?id='+id,
url: '/pages/goods/goods?id=' + id
});
},
},
}
}
};
</script>
......@@ -611,7 +603,7 @@ export default {
.cartStyle {
height: 100%;
position: relative;
font-family: "oswald";
font-family: 'oswald';
}
.cartStyle .u-checkbox__label {
......@@ -699,12 +691,11 @@ export default {
.cartStyle .Deletestyle {
margin-right: 40rpx;
}
.cartStyle .invalid{
.cartStyle .invalid {
text-align: center;
width: 40px;
height: 20px;
line-height: 20px;
border-radius: 10px;
}
</style>
<template>
<div class="cartStyle" v-if="!isloading" :style="{ height: contentHeight }">
<view
style="
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 15rpx;
"
>
<Text class="grid-text">商品库存有限,请尽快下单哦</Text>
<Text @click="edit" v-if="editType == false" class="grid-text_r">编辑</Text>
<Text @click="edit" v-if="editType == true" class="grid-text_r">完成</Text>
</view>
<view style="width: 100%; height: 30rpx; background: #f7f7f7; margin: 20rpx 0;"></view>
<u-empty v-if="list.length == 0" text="购物车还是空的哦" mode="car"></u-empty>
<view
v-if="list.length > 0"
style="
height: calc(100vh - 60px);
width: calc(100vw);
overflow: hidden;
padding-top: 10px;
"
>
<scroll-view :scroll-y="true" :enable-back-to-top="true" :enable-flex="true" :style="{ height: '100%' }">
<template v-if="list.length > 0">
<view class="cartList" :style="{ 'margin-bottom': listbottom }" v-for="(c, i) in list" :key="i">
<view
style="
padding: 0 12px 12px 12px;
border-bottom: 1rpx solid #f5f5f5;
width: 100%;
"
>
<u-checkbox-group @change="mch_SelectAll(c.checked, i)">
<u-checkbox v-model="c.checked" shape="circle" :active-color="mc">{{ c.MallName }}</u-checkbox>
</u-checkbox-group>
</view>
<view class="cartList_item" v-for="(item, index) in c.GoodsList" :key="index" :name="item.GoodsName">
<view style="width: 40px;text-align: center;" v-if="item.GoodsStatus == 1 || editType == true">
<u-checkbox-group @change="clickcheckbox(item.checked, item.Price, index, i)">
<u-checkbox v-model="item.checked" shape="circle" :active-color="mc"></u-checkbox>
</u-checkbox-group>
</view>
<view class="invalid" :style="{ background: mc }" v-if="item.GoodsStatus != 1 && editType == false">
<Text style="color: #fff; width: 22px;font-size: 20rpx;">失效</Text>
</view>
<image
:src="item.CoverImage"
mode="aspectFill"
style="
width: 150rpx;
height: 150rpx;
margin-left: 30rpx;
border-radius: 5px;
"
@click="clickHandler(item.GoodsId)"
/>
<view
style="
display: flex;
flex-direction: column;
justify-content: space-between;
width: 440rpx;
height: 150rpx;
margin-left: 20rpx;
"
>
<Text
style="
font-size: 28rpx;
width: 440rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
"
>
{{ item.GoodsName}}
</Text>
<view
style="
width: 440rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
"
>
<view v-for="(attr, inde2x) in item.SpecificationList" :key="inde2x">
<Text
style="
color: #a0a09d;
font-size: 24rpx;
margin-right: 5rpx;
"
>
{{ attr}}
</Text>
</view>
</view>
<view
style="
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
"
>
<Text style="font-size: 30rpx;" :style="{ color: mc }">
<Text style="40rpx">{{ item.Price }}</Text>
</Text>
<u-number-box
v-model="item.Number"
:min="1"
:max="item.InventoryNum"
@change="valChange(i, index, item.Number, item.Price, $event)"
></u-number-box>
</view>
<Text v-if="item.GoodsStatus != 1 && editType == false" style="font-size: 20rpx;color:#a0a09d ;">失效原因:商品下架或者库存不足</Text>
</view>
</view>
</view>
</template>
</scroll-view>
</view>
<view class="box_bottom">
<div style="margin-left: 30rpx;">
<u-checkbox-group @change="SelectAll">
<u-checkbox v-model="allchecked" shape="circle" :active-color="mc">全选</u-checkbox>
</u-checkbox-group>
<Text style="font-size: 30rpx;" :style="{ color: mc }" v-if="editType == false">¥{{ TotalPrice }}</Text>
</div>
<div class="bottom_btn" v-if="!editType">
<u-button
size="80"
:ripple="true"
shape="circle"
@click="settlement"
:custom-style="{
backgroundColor: mc,
height: '80rpx',
color: '#FFF',
fontSize: '14px'
}"
>
去结算({{ checkCount }})
</u-button>
</div>
<u-button
v-if="editType"
size="80"
:ripple="true"
shape="circle"
@click="delete_btn"
:custom-style="{
backgroundColor: secondary,
height: '80rpx',
color: '#FFF',
fontSize: '14px',
marginRight: '12px'
}"
>
删除
</u-button>
</view>
<tabbars></tabbars>
</div>
</template>
<script>
import tabbars from '@/components/tabbar/index';
export default {
data() {
return {
isloading: true,
pageTitle: '购物车',
navHeight: 0,
contentHeight: 0,
cstyle: {},
allchecked: false,
TotalPrice: 0, //总价格
bottommargin: 0,
listbottom: 0,
editType: false,
list: [],
cart_id_list: [],
mc: '',
secondary: '',
checkCount: 0,
msg: {
pageIndex: 1,
pageSize: 50,
Name: ''
}
};
},
created() {},
components: {
tabbars
},
onLoad() {
this.navHeight = this.$navHeight - 2;
this.mc = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
this.cstyle = uni.getStorageSync('basedata') ? uni.getStorageSync('basedata').cat_style : [];
if (this.cstyle.cat_style == '4') {
}
},
mounted() {
let currentPages = getCurrentPages();
let c = this.$uiConfig.is_bang ? 80 : 52;
this.bottommargin = c - 2 + 'px';
this.listbottom = c + 44 + 'px';
this.contentHeight = this.$utils.calcContentHeight(c - 42) + 'px';
let u = '/' + currentPages[currentPages.length - 1].route;
let pages = wx.getStorageSync('basedata') ? wx.getStorageSync('basedata').bar_title : [];
pages.forEach(x => {
if (x.value == u) {
this.pageTitle = x.new_name ? x.new_name : x.name;
}
});
uni.setNavigationBarTitle({
title: this.pageTitle
});
this.init();
},
methods: {
goHome() {
uni.redirectTo({
url: '/pages/index/main'
});
},
init() {
uni.showNavigationBarLoading();
let h = this.apiheader();
this.request2(
{
url: '/api/AppletOrder/GetGoodsShoppingCartPageList',
data: this.msg
},
res => {
this.loading = false;
if (res.resultCode == 1) {
uni.hideNavigationBarLoading();
this.isloading = false;
if (res.data.pageData.length > 0) {
let list = res.data.pageData;
list.forEach(x => {
x.checked = false;
x.GoodsList.forEach(j => {
j.checked = false;
j.id=j.Id;
});
});
this.list = list;
} else {
this.list = [];
}
}
uni.hideNavigationBarLoading();
}
);
// this.request(
// {
// url: '',
// header: h,
// data: {
// r: 'api/cart/list'
// }
// },
// res => {
// uni.hideNavigationBarLoading();
// this.isloading = false;
// if (res.data.list.length > 0) {
// let list = res.data.list;
// list.forEach(x => {
// x.checked = false;
// x.goods_list.forEach(j => {
// j.checked = false;
// });
// });
// this.list = list;
// } else {
// this.list = [];
// }
// }
// );
},
clickcheckbox(checked, price, index, i) {
// (item.checked, item.Price, index, i)
if (checked == true) {
this.checkCount += 1;
this.TotalPrice += parseFloat((price * this.list[i].GoodsList[index].Number).toFixed(2));
let goods_list_all = true; //判断该商场是否全选
this.list[i].GoodsList.forEach(x => {
if (this.editType == false) {
//编辑的时候不判断
if (x.checked == false && x.new_status == 0) {
goods_list_all = false;
}
} else {
if (x.checked == false) {
goods_list_all = false;
}
}
});
if (goods_list_all == true) {
this.list[i].checked = true;
}
let list_all = true; //判断所有商场是否全选
this.list.forEach(x => {
if (x.checked == false) {
list_all = false;
}
});
if (list_all == true) {
this.allchecked = true;
}
if (this.editType == true) {
let obj = {
mch_id: 0,
id: this.list[i].GoodsList[index].id
};
this.cart_id_list.push(obj);
}
} else {
this.TotalPrice -= parseFloat((price * this.list[i].GoodsList[index].Number).toFixed(2));
this.checkCount -= 1;
this.allchecked = false;
let goods_list_all = true; //判断该商场是否全选
this.list[i].GoodsList.forEach(x => {
if (x.checked == false) {
goods_list_all = false;
}
});
if (goods_list_all == false) {
this.list[i].checked = false;
}
if (this.editType == true) {
this.cart_id_list.forEach((x, j) => {
if (x.id == this.list[i].GoodsList[index].id) {
this.cart_id_list.splice(j, 1);
}
});
}
}
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
mch_SelectAll(checked, i) {
if (checked == true) {
let add_cartlist = [];
let new_statusnum = 0;
this.list[i].GoodsList.forEach(x => {
if (x.GoodsStatus == 1) {
if (x.checked == false) {
this.TotalPrice += parseFloat((x.Price * x.Number).toFixed(2));
x.checked = true;
new_statusnum++;
}
}
//编辑时候的商城全选
if (this.editType == true) {
if (this.cart_id_list.length > 0) {
this.cart_id_list.forEach(z => {
if (x.id != z.id) {
let obj = {
mch_id: 0,
id: x.id
};
add_cartlist.push(obj);
}
});
} else {
let obj = {
mch_id: 0,
id: x.id
};
add_cartlist.push(obj);
}
}
});
this.cart_id_list = this.cart_id_list.concat(add_cartlist);
let list_all = true; //判断所有商场是否全选
this.list.forEach(x => {
if (x.checked == false) {
list_all = false;
}
});
if (list_all == true) {
this.allchecked = true;
}
this.checkCount += new_statusnum;
} else {
let new_statusnum = 0;
this.list[i].GoodsList.forEach(x => {
if (x.GoodsStatus == 1) {
x.checked = false;
this.TotalPrice -= parseFloat((x.Price * x.Number).toFixed(2));
new_statusnum++;
}
//编辑时候的商城全选
this.cart_id_list.forEach((z, m) => {
if (x.id == z.id) {
this.cart_id_list.splice(m, 1);
}
});
});
this.allchecked = false;
this.checkCount -= new_statusnum;
}
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
SelectAll() {
let list = this.list;
if (this.allchecked == true) {
this.checkCount = 0;
this.TotalPrice = 0;
this.cart_id_list = [];
list.forEach(x => {
x.checked = true;
x.GoodsList.forEach(j => {
if (j.GoodsStatus == 1) {
j.checked = true;
this.checkCount++;
this.TotalPrice += parseFloat((j.Price * j.Number).toFixed(2));
}
//编辑的时候
if (this.editType == true) {
this.cart_id_list.push({
mch_id: 0,
id: j.id
});
}
});
});
} else {
this.checkCount = 0;
this.TotalPrice = 0;
this.cart_id_list = [];
list.forEach(x => {
x.checked = false;
x.GoodsList.forEach(j => {
j.checked = false;
});
});
}
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
valChange(i, index, Number, p, e) {
// (i, index, item.Number, item.Price, $event)
let value = parseFloat(e.value);
let price = parseFloat(p);
if (Number > value) {
this.list[i].GoodsList[index].Number = value;
if (this.list[i].GoodsList[index].checked == true) {
this.TotalPrice -= parseFloat((price * (Number - value)).toFixed(2));
}
} else if (value > Number) {
this.list[i].GoodsList[index].Number = value;
if (this.list[i].GoodsList[index].checked == true) {
this.TotalPrice += parseFloat((price * (value - Number)).toFixed(2));
}
}
this.TotalPrice = parseFloat(this.TotalPrice.toFixed(2));
},
edit() {
this.editType = !this.editType;
this.allchecked = false;
this.TotalPrice = 0;
this.checkCount = 0;
this.cart_id_list = [];
let list = this.list;
list.forEach(x => {
x.checked = false;
x.GoodsList.forEach(j => {
j.checked = false;
});
});
},
delete_btn() {
if (this.cart_id_list.length > 0) {
uni.showNavigationBarLoading();
let arr=[];
this.cart_id_list.forEach(item=>{
arr.push(item.id);
})
this.request2(
{
url: '/api/AppletOrder/DelGoodsShoppingCartInfo',
data: {ShoppingCartIdList:arr}
},
res => {
if(res.resultCode==1){
this.init();
this.TotalPrice = 0;
this.editType = false;
this.allchecked = false;
this.checkCount = 0;
}
uni.hideNavigationBarLoading();
}
);
// this.request(
// {
// url: '',
// method: 'POST',
// header: h,
// data: {
// r: 'api/cart/delete',
// cart_id_list: JSON.stringify(this.cart_id_list)
// }
// },
// res => {
// this.init();
// this.TotalPrice = 0;
// this.editType = false;
// this.allchecked = false;
// this.checkCount = 0;
// uni.hideNavigationBarLoading();
// }
// );
} else {
uni.showToast({
title: '请选择需要删除的商品',
position: 'bottom',
icon: 'none',
duration: 2000
});
}
},
settlement() {
if (this.checkCount > 0) {
let forms = {
list: [],
address_id: 0
};
this.list.forEach(y => {
let good = {
// MallId: y.MallId,
DetailList: [],
distance: 0,
remark: '',
order_form: [],
Use_Integral: 0,
User_Coupon_Id: 2,
DeliveryMethod:1,
AddressId:0,
};
y.GoodsList.forEach(x => {
if (x.checked) {
let g = {
GoodsId: x.GoodsId,
Number: x.Number,
SpecificationList: x.SpecificationList,
};
good.DetailList.push(g);
}
});
forms.list.push(good);
console.log("forms",forms)
});
return;
uni.navigateTo({
url: '/pages/order-submit/order-submit?formData=' + encodeURIComponent(JSON.stringify(forms))
});
} else {
uni.showToast({
title: '请选择购买商品',
position: 'bottom',
icon: 'none',
duration: 2000
});
}
},
clickHandler(id) {
uni.navigateTo({
url: '/pages/goods/goods?id=' + id
});
}
}
};
</script>
<style>
.cartStyle {
height: 100%;
position: relative;
font-family: 'oswald';
}
.cartStyle .u-checkbox__label {
margin-left: 12px;
}
.cartStyle .grid-text {
font-size: 24rpx;
margin-top: 4rpx;
color: #939393;
}
.cartStyle .grid-text_r {
margin-top: 4rpx;
margin-right: 10rpx;
}
.cartStyle .cartList {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
overflow-y: hidden;
}
.cartStyle .cartList .cartList_item {
width: 100%;
padding: 30rpx 30rpx 30rpx 10rpx;
display: flex;
flex-direction: row;
align-items: center;
border-bottom: 1rpx solid #f5f5f5;
}
.cartList .cartList_item .item_input {
width: 200rpx;
height: 60rpx;
background: #f7f7f7;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.cartList .item_input .item_input_l,
.item_input_r {
width: 50rpx;
height: 60rpx;
font-size: 28rpx;
display: flex;
align-items: center;
justify-content: center;
}
.cartStyle .item_input .item_input_c {
text-align: center;
width: 50rpx;
height: 60rpx;
font-size: 20rpx;
}
.cartStyle .box_bottom {
width: 100%;
height: 50px;
position: absolute;
background: #fff;
left: 0;
bottom: 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
border-top: 1rpx solid #f5f5f5;
z-index: 999;
}
.cartStyle .bottom_btn {
display: flex;
align-items: center;
justify-content: center;
width: 250rpx;
height: 50px;
}
.cartStyle .Deletestyle {
margin-right: 40rpx;
}
.cartStyle .invalid {
text-align: center;
width: 40px;
height: 20px;
line-height: 20px;
border-radius: 10px;
}
</style>
......@@ -167,7 +167,7 @@ export default {
this.showLoading = this.msg.pageIndex != 1;
this.request2(
{
url: '/api/AppletGoods/GetAppletGoodsPageList',
url: '/api/AppletGoods/GetAppletGoodsPageListForZY',
data: this.msg
},
res => {
......
<template>
<view class="ordersubmit" v-if="!loading">
<view class="add-box" @click="chosenAddress(ds.address.id)">
<view class="add-info">
<view class="address">
{{ address.province + address.city + address.district }}
</view>
<view v-if="address.province && address.province != ''" class="add-info">
<view class="address">{{ address.province + address.city + address.district }}</view>
<view class="area">{{ address.detail }}</view>
<view class="address">
<text style="margin-right: 10px;">{{ address.name }}</text>
<text>{{ address.mobile }}</text>
</view>
</view>
<view class="arrow">
<u-icon name="arrow" size="32" color="#444"></u-icon>
<view v-else class="add-info">
<span style="position: relative;top: 16rpx;">请选择</span>
</view>
<view class="arrow"><u-icon name="arrow" size="32" color="#444"></u-icon></view>
</view>
<view class="pay">
<view>支付方式</view>
......@@ -30,14 +29,16 @@
<image :src="y.cover_pic" mode="aspectFill" class="image" />
<view class="goodinfo">
<view class="name">{{ y.name }}</view>
<view class="attr">已选择 {{ y.attrStr }}</view>
<view class="attr">已选择:
<span v-for="(item,index3) in y.specificationNameList" :ket="index3">
{{item}}
</span>
</view>
<view class="price">
<view class="left" :style="{ color: mc }">
<text class="small"></text>
<text>{{ y.goods_attr.price.split(".")[0] }}</text>
<text class="small"
>.{{ y.goods_attr.price.split(".")[1] || "00" }}</text
>
<text>{{ y.goods_attr.price }}</text>
<!-- <text class="small">.{{ y.goods_attr.price.split('.')[1] || '00' }}</text> -->
</view>
<view class="right">x{{ y.num }}</view>
</view>
......@@ -47,88 +48,37 @@
<template v-else>
<view class="goodboxmore">
<view class="good-list">
<view style="white-space: nowrap">
<image
v-for="(y, yi) in x.goods_list"
:key="yi"
:src="y.cover_pic"
mode="aspectFill"
class="item"
/>
</view>
<view style="white-space: nowrap"><image v-for="(y, yi) in x.goods_list" :key="yi" :src="y.cover_pic" mode="aspectFill" class="item" /></view>
</view>
<view class="infos">
<view class="text">{{ x.goods_list.length }}</view>
<u-icon
name="ellipsis"
size="36"
@click="showGoodListHandler(i)"
></u-icon>
<u-icon name="ellipsis" size="36" @click="showGoodListHandler(i)"></u-icon>
</view>
</view>
</template>
<view class="peisong">
<view>配送</view>
<view style="text-align: right; padding-right: 5px;">
{{ x.delivery.send_type_name }}
</view>
<u-icon
name="ellipsis"
size="36"
@click="showPeisongHandler(i)"
></u-icon>
<peisong
:list="x.delivery.send_type_list"
:index="i"
@close="changeSendTypeHandler"
:send-type="x.delivery.send_type"
v-if="x.delivery.showDelivery"
></peisong>
</view>
<view class="liuyan">
<u-field
padding="0px"
label-width="80"
v-model="x.form_data.remark"
label="留言"
placeholder="建议留言前先与客服沟通确认"
></u-field>
<view style="text-align: right; padding-right: 5px;">{{ x.delivery.send_type_name }}</view>
<u-icon name="ellipsis" size="36" @click="showPeisongHandler(i)"></u-icon>
<peisong :list="x.delivery.send_type_list" :index="i" @close="changeSendTypeHandler" :send-type="x.delivery.send_type" v-if="x.delivery.showDelivery"></peisong>
</view>
<view class="liuyan"><u-field padding="0px" label-width="80" v-model="BuyerMessage" label="留言" placeholder="建议留言前先与客服沟通确认"></u-field></view>
</view>
</view>
<view class="discountbox">
<view class="filed">
<view class="left">优惠券</view>
<view class="right">
<text class="content" v-if="mchs[0].coupon.user_coupon_id == 0"
>选择优惠券</text
>
<text class="content" v-else :style="{ color: mc }"
>已优惠{{ mchs[0].coupon.coupon_discount }}元</text
>
<u-icon
name="ellipsis"
size="36"
v-if="couponList.length > 0"
@click="showCouponHandler"
></u-icon>
<text class="content" v-if="mchs[0].coupon.user_coupon_id == 0">选择优惠券</text>
<text class="content" v-else :style="{ color: mc }">已优惠{{ mchs[0].coupon.coupon_discount }}元</text>
<u-icon name="ellipsis" size="36" v-if="couponList.length > 0" @click="showCouponHandler"></u-icon>
</view>
</view>
<view class="filed" v-if="integral.can_use">
<view class="left">积分抵扣</view>
<view class="right">
<text class="content" :style="{ color: secondary }">
{{ `使用${integral.use_num}积分抵扣${integral.deduction_price}元` }}
</text>
<u-checkbox-group>
<u-checkbox
v-model="userInt"
:active-color="mc"
@change="changeUseInt"
:icon-size="28"
shape="circle"
></u-checkbox>
</u-checkbox-group>
<text class="content" :style="{ color: secondary }">{{ `使用${integral.use_num}积分抵扣${integral.deduction_price}元` }}</text>
<u-checkbox-group><u-checkbox v-model="userInt" :active-color="mc" @change="changeUseInt" :icon-size="28" shape="circle"></u-checkbox></u-checkbox-group>
</view>
</view>
<!-- <view class="filed">
......@@ -149,33 +99,27 @@
<view class="filed">
<view class="left">运费</view>
<view class="right">
<text class="price" :style="{ color: mc }"
>+¥{{ expressPrice.toFixed(2) }}</text
>
<text class="price" :style="{ color: mc }">+¥{{ expressPrice.toFixed(2) }}</text>
</view>
</view>
<view class="filed">
<view class="left">优惠</view>
<view class="right">
<text class="price" :style="{ color: mc }"
>-¥{{ couponPrice.toFixed(2) }}</text
>
<text class="price" :style="{ color: mc }">-¥{{ couponPrice.toFixed(2) }}</text>
</view>
</view>
<view class="filed" v-if="integral.can_use">
<view class="left">积分抵扣</view>
<view class="right">
<text class="price" :style="{ color: mc }">
-¥{{ userInt ? integral.deduction_price.toFixed(2) : "0.00" }}
</text>
<text class="price" :style="{ color: mc }">-¥{{ userInt ? integral.deduction_price.toFixed(2) : '0.00' }}</text>
</view>
</view>
</view>
<view class="btton-box">
<view class="left" :style="{ color: mc }">
<text></text>
<text class="bold">{{ ds.total_price.split(".")[0] }}</text>
<text>.{{ ds.total_price.split(".")[1] || "00" }}</text>
<text class="bold">{{ ds.total_price }}</text>
<!-- <text>.{{ ds.total_price.split('.')[1] || '00' }}</text> -->
</view>
<view class="right">
<u-button
......@@ -187,61 +131,76 @@
backgroundColor: mc,
height: '80rpx',
color: '#FFF',
fontSize: '14px',
fontSize: '14px'
}"
>
<u-loading
mode="circle"
style="margin-right: 5px;"
v-if="submitOrder"
></u-loading
>提交订单
<u-loading mode="circle" style="margin-right: 5px;" v-if="submitOrder"></u-loading>
提交订单
</u-button>
</view>
</view>
<coupon
v-if="couponList.length > 0 && showCoupon"
:list="couponList"
:current="formData.list[0].user_coupon_id"
@close="closeCouponHandler"
></coupon>
<coupon v-if="couponList.length > 0 && showCoupon" :list="couponList" :current="formData.list[0].user_coupon_id" @close="closeCouponHandler"></coupon>
<view class="notOption" v-if="submitOrder"></view>
<good-list :list="goodData" v-if="showGoodList" @close="closeGoodListHandler"></good-list>
<payCom v-if="payBtn" :payInfo="payInfo" @closePay="closePay"></payCom>
<u-toast ref="uToast" />
<u-popup v-model="payExit" mode="center" :mask-close-able="false">
<view style="background:#fff;width:500rpx">
<view style="padding:10px 0 0 10px">提交失败</view>
<view style="text-align:center;padding-bottom:40rpx">
<view style="margin:80rpx 0">支付取消</view>
<span @click="exitPay" style="padding:10rpx 50rpx;color:#fff;background:#19be6b;border-radius: 12px;">确定</span>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import peisong from "@/components/peisong/index";
import coupon from "@/components/coupon/index";
import goodList from '@/components/goods/order-good-list'
import payCom from '@/components/pay/pay';
import peisong from '@/components/peisong/index';
import coupon from '@/components/coupon/index';
import goodList from '@/components/goods/order-good-list';
export default {
components: {
payCom,
peisong,
coupon,
goodList
},
data() {
return {
payExit: false,
payBtn: false,
formData: {
list: [
{
mch_id: 0,
goods_list: [],
distance: 0,
remark: "",
remark: '',
order_form: [],
use_integral: 0,
user_coupon_id: 0,
},
user_coupon_id: 0
}
],
address_id: 0,
address_id: 0
},
pageTitle: "填写订单",
formdata: {
// DetailList: [{ GoodsId: 31, Number: 1, SpecificationSort: '1' }, { GoodsId: 38, Number: 1, SpecificationSort: '0:0' }],
// Use_Integral: 0,
// User_Coupon_Id: 0,
// DeliveryMethod: 0,
// AddressId: 0
},
DeliveryMethod: '',
pageTitle: '填写订单',
address: {},
mchs: [],
mc: "",
mc: '',
ds: {
total_price: "0.00",
total_price: '0.00'
},
expressPrice: 0.0,
goodPrice: 0.0,
......@@ -250,91 +209,149 @@ export default {
can_use: false,
use: false,
use_num: 0,
deduction_price: 0,
deduction_price: 0
},
secondary: "",
secondary: '',
userInt: false,
loading: true,
couponList: [],
showCoupon: false,
submitOrder: false,
isLeave: false,
goodData:[],
showGoodList:false
goodData: [],
showGoodList: false,
DetailList: [],
IsFormShoppingCart: 1,
adressInfo: {},
payInfo: {
OpenId: 'ow_7I5XC1-RGwwk8QANBmWKYKmOc',
OrderId: '',
OrderPayType: 1,
GoodsName: ''
},
ShoppingCartIdList: [6, 5]
};
},
onLoad(option) {
if (option.goods) {
this.formData.list[0].goods_list = JSON.parse(decodeURIComponent(option.goods));
} else if (option.formData) {
}
if (option.formData) {
this.formData = JSON.parse(decodeURIComponent(option.formData));
} else {
uni.redirectTo({
url: '/pages/index/index'
});
this.formdata = JSON.parse(decodeURIComponent(option.formData));
}
if (option.IsFormShoppingCart) {
this.IsFormShoppingCart = option.IsFormShoppingCart;
}
if (option.ShoppingCartIdList) {
this.ShoppingCartIdList = JSON.parse(option.ShoppingCartIdList);
}
// else {
// uni.redirectTo({
// url: '/pages/index/index'
// });
// }
this.initPage();
this.mc = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
},
onShow() {
this.init();
this.initCoupon();
if (this.isLeave) {
uni.navigateBack({
delta: 1,
delta: 1
});
}
},
methods: {
closeGoodListHandler(){
this.goodData=[]
this.showGoodList=false
exitPay() {
this.payExit = false;
uni.redirectTo({
url: "/pages/order/index/index",
});
},
closePay() {
this.payBtn = false;
this.payExit = true;
},
closeGoodListHandler() {
this.goodData = [];
this.showGoodList = false;
},
showGoodListHandler(i){
this.goodData=this.mchs[i].goods_list
this.showGoodList=true
showGoodListHandler(i) {
this.goodData = this.mchs[i].goods_list;
this.showGoodList = true;
},
// 提交订单
submitOrderHandler() {
let that = this;
console.log('that.adressInfo', this.adressInfo);
if (that.adressInfo.Consignee == '') {
this.$refs.uToast.show({
title: '请选择收货信息!',
type: 'warning'
});
return;
}
if (!this.submitOrder) {
this.submitOrder = true;
let that=this
uni.requestSubscribeMessage({
tmplIds: this.ds.template_message_list,
complete (res) {
complete(res) {
that.submitOrder = false;
let list = [];
that.mchs.forEach((x) => {
list.push(x.form_data);
});
let forms = {
list,
};
forms.address_id = that.ds.address.id;
forms.address = {
name: that.ds.address.name,
mobile: that.ds.address.mobile,
};
console.log(forms);
let h = that.apiheader();
h["content-type"] = "application/x-www-form-urlencoded";
that.request(
let form = {};
form.Consignee = that.adressInfo.Consignee;
form.Mobile = that.adressInfo.Mobile;
form.Province = that.adressInfo.Province;
form.City = that.adressInfo.City;
form.District = that.adressInfo.District;
form.ShoppingAddress = that.adressInfo.ShoppingAddress;
form.BuyerMessage = that.BuyerMessage;
form.DeliveryMethod = that.formdata.DeliveryMethod;
form.DetailList = that.DetailList;
form.User_Coupon_Id = that.formdata.User_Coupon_Id;
form.CouponMoney = that.couponPrice;
form.FreightMoney = that.expressPrice;
form.Income = that.ds.total_price;
form.IsFormShoppingCart = that.IsFormShoppingCart;
form.Use_Integral = that.formdata.Use_Integral;
form.ShoppingCartIdList = that.ShoppingCartIdList;
that.request2(
{
data: {
r: "api/order/submit",
form_data: JSON.stringify(forms),
url: '/api/AppletOrder/SetAppletGoodsOrderInfo',
data: form
},
header: h,
method: "POST",
},
(res) => {
console.log(res.data);
//TODO 未实现 支付 开始调起支付
res => {
console.log('res', res);
if (res.resultCode == 1) {
that.payBtn = true;
that.payInfo.OrderId = res.data.OrderId;
that.payInfo.total_price = that.ds.total_price;
}
uni.navigateTo({
url: '/pages/order-submit/pay-success'
});
uni.hideNavigationBarLoading();
}
);
// let h = that.apiheader();
// h["content-type"] = "application/x-www-form-urlencoded";
// that.request(
// {
// data: {
// r: "api/order/submit",
// form_data: JSON.stringify(forms),
// },
// header: h,
// method: "POST",
// },
// (res) => {
// console.log(res.data);
// //TODO 未实现 支付 开始调起支付
// uni.navigateTo({
// url: '/pages/order-submit/pay-success'
// });
// uni.showModal({
// title: "下单提醒",
......@@ -351,18 +368,18 @@ export default {
// }
// },
// });
// }
// );
}
);
}
})
});
}
},
closeCouponHandler(e) {
if (e != -1) {
this.formData.list.forEach((x) => {
x.user_coupon_id = e;
});
// this.formData.list.forEach(x => {
// x.user_coupon_id = e;
// });
this.formdata.User_Coupon_Id = e;
this.init();
}
this.showCoupon = false;
......@@ -371,26 +388,59 @@ export default {
this.showCoupon = true;
},
initCoupon() {
let h = this.apiheader();
h["content-type"] = "application/x-www-form-urlencoded";
this.request(
let ProductList = [];
this.DetailList = [];
this.mchs.forEach(item => {
item.goods_list.forEach(list => {
let obj = {
GoodsClassId: list.categoryIdList,
GoodsPrice: list.total_price,
ProductId: list.id
};
let obj1 = {
SpecificationSort: list.goods_attr.sign_id,
Number: list.num,
GoodsId: list.id,
SpecificationList: list.specificationNameList
};
ProductList.push(obj);
this.DetailList.push(obj1);
});
});
this.request2(
{
url: "",
data: {
r: "api/order/usable-coupon-list",
form_data: JSON.stringify(this.formData.list[0]),
},
header: h,
method: "POST",
url: '/api/AppletCoupon/GetNoUseCouponList',
data: { ProductList: ProductList }
},
(res) => {
this.couponList = res.data.list;
res => {
console.log('优惠券', res);
if (res.resultCode == 1) {
this.couponList = res.data;
}
}
);
// let h = this.apiheader();
// h["content-type"] = "application/x-www-form-urlencoded";
// this.request(
// {
// url: "",
// data: {
// r: "api/order/usable-coupon-list",
// form_data: JSON.stringify(this.formData.list[0]),
// },
// header: h,
// method: "POST",
// },
// (res) => {
// this.couponList = res.data.list;
// }
// );
},
changeSendTypeHandler(e) {
let i = e.index;
console.log(i);
let obj = this.mchs[i];
obj.delivery.showDelivery = false;
this.$set(this.mchs, i, obj);
......@@ -398,6 +448,7 @@ export default {
if (e && e.val) {
if (this.mchs[i].delivery.send_type != e.val) {
this.formData.list[i].send_type = e.val;
this.formdata.DeliveryMethod = e.val;
this.init();
}
}
......@@ -409,49 +460,47 @@ export default {
this.$forceUpdate();
},
chosenAddress(id) {
console.log('chosenAddress');
uni.navigateTo({
url: "/pages/address/address_chosen?form=ordersubmit&id=" + id,
url: '/pages/address/address?form=ordersubmit&id=' + id
});
},
changeUseInt(e) {
this.userInt = e.value;
this.formData.list.forEach((x) => {
this.formData.list.forEach(x => {
x.use_integral = this.userInt ? 1 : 0;
this.formData.Use_Integral = this.userInt ? 1 : 0;
});
this.init();
},
initPage() {
let currentPages = getCurrentPages();
let u = "/" + currentPages[currentPages.length - 1].route;
let pages = uni.getStorageSync("basedata")
? uni.getStorageSync("basedata").bar_title
: [];
pages.forEach((x) => {
let u = '/' + currentPages[currentPages.length - 1].route;
let pages = uni.getStorageSync('basedata') ? uni.getStorageSync('basedata').bar_title : [];
pages.forEach(x => {
if (x.value == u) {
this.pageTitle = x.new_name ? x.new_name : x.name;
}
});
uni.setNavigationBarTitle({
title: this.pageTitle,
title: this.pageTitle
});
},
init() {
this.loading = true;
let h = this.apiheader();
h["content-type"] = "application/x-www-form-urlencoded";
this.request(
this.request2(
{
url: "",
data: {
r: "api/order/preview",
form_data: JSON.stringify(this.formData),
url: '/api/AppletOrder/GetAppletGoodsSettlementInfoForZY',
data: this.formdata
},
header: h,
method: "POST",
},
(res) => {
res => {
this.loading = false;
if (res.resultCode == 1) {
this.address = res.data.address;
this.mchs = res.data.mch_list;
this.payInfo.GoodsName = this.mchs[0].goods_list[0].name;
console.log('this.payInfo.GoodsName', this.payInfo.GoodsName);
this.ds = res.data;
this.expressPrice = 0.0;
this.goodPrice = 0.0;
......@@ -460,19 +509,59 @@ export default {
can_use: false,
use: false,
use_num: 0,
deduction_price: 0,
deduction_price: 0
};
this.formatPrice();
this.formatAttr();
this.loading = false;
this.initCoupon();
// this.formatAttr();
this.adressInfo = {
Consignee: this.address.name,
Mobile: this.address.mobile,
Province: this.address.province_id,
City: this.address.city_id,
District: this.address.district_id,
ShoppingAddress: this.address.detail
};
}
uni.hideNavigationBarLoading();
}
);
// let h = this.apiheader();
// h["content-type"] = "application/x-www-form-urlencoded";
// this.request(
// {
// url: "",
// data: {
// r: "api/order/preview",
// form_data: JSON.stringify(this.formData),
// },
// header: h,
// method: "POST",
// },
// (res) => {
// this.address = res.data.address;
// this.mchs = res.data.mch_list;
// this.ds = res.data;
// this.expressPrice = 0.0;
// this.goodPrice = 0.0;
// this.couponPrice = 0.0;
// this.integral = {
// can_use: false,
// use: false,
// use_num: 0,
// deduction_price: 0,
// };
// this.formatPrice();
// this.formatAttr();
// this.loading = false;
// }
// );
},
formatPrice() {
this.mchs.forEach((x) => {
this.mchs.forEach(x => {
x.delivery.showDelivery = false;
x.delivery.send_type_list.forEach((y) => {
console.log(y.value == x.delivery.send_type);
x.delivery.send_type_list.forEach(y => {
if (y.value == x.delivery.send_type) {
x.delivery.send_type_name = y.name;
}
......@@ -484,28 +573,26 @@ export default {
this.integral.can_use = true;
this.integral.use = false;
this.integral.use_num += x.integral.use_num;
this.integral.deduction_price += parseFloat(
x.integral.deduction_price
);
this.integral.deduction_price += parseFloat(x.integral.deduction_price);
}
});
},
formatAttr() {
this.mchs.forEach((x) => {
this.mchs.forEach(x => {
this.userInt = x.integral.use;
x.goods_list.forEach((y) => {
let attrStr = "";
x.goods_list.forEach(y => {
let attrStr = '';
y.attr_list.forEach((z, i) => {
if (i > 0) {
attrStr += " ";
attrStr += ' ';
}
attrStr += z.attr_group_name + " " + z.attr_name;
attrStr += z.attr_group_name + ' ' + z.attr_name;
});
y.attrStr = attrStr;
});
});
},
},
}
}
};
</script>
......@@ -519,7 +606,7 @@ export default {
padding: 0 5px;
background: #f6f6f6;
padding-bottom: 40px;
font-family: "oswald";
font-family: 'oswald';
}
.ordersubmit .add-box {
......@@ -560,19 +647,9 @@ export default {
bottom: 0;
left: 0;
height: 2px;
background: repeating-linear-gradient(
-45deg,
#ff6c6c 0,
#ff6c6c 20%,
transparent 0,
transparent 25%,
#1989fa 0,
#1989fa 45%,
transparent 0,
transparent 50%
);
background: repeating-linear-gradient(-45deg, #ff6c6c 0, #ff6c6c 20%, transparent 0, transparent 25%, #1989fa 0, #1989fa 45%, transparent 0, transparent 50%);
background-size: 80px;
content: "";
content: '';
}
.ordersubmit .pay {
margin-bottom: 12px;
......@@ -635,7 +712,7 @@ export default {
}
.ordersubmit .goodbox .goodinfo .price .left {
font-size: 20px;
font-family: "oswald";
font-family: 'oswald';
width: 1px;
flex: 1;
}
......@@ -725,7 +802,7 @@ export default {
font-size: 16px;
flex: 1;
text-align: right;
font-family: "oswald";
font-family: 'oswald';
}
.ordersubmit .btton-box {
height: 50px;
......@@ -752,7 +829,7 @@ export default {
.ordersubmit .btton-box .left {
font-size: 16px;
flex: 1;
font-family: "oswald";
font-family: 'oswald';
}
.ordersubmit .btton-box .left .bold {
font-size: 24px;
......
<template>
<view>
<u-button @click="Pay">支付</u-button>
</view>
</template>
<script>
export default {
data() {
return {
payInfo:{},
}
},
created(){
this.getDataInfo();
},
methods: {
getDataInfo() {
let msg={
"OpenId":"ow_7I5XC1-RGwwk8QANBmWKYKmOc",
"OrderId":"1",
"OrderPayType":1,
"GoodsName":"测试商品名称"
}
this.request2(
{
url: '/api/WeChatPay/GetPayInfo',
data: msg
},
res => {
console.log("res",res);
if(res.resultCode==1){
this.payInfo=JSON.parse(res.data);
console.log("getDataInfo",this.payInfo);
}
uni.hideNavigationBarLoading();
}
);
},
Pay(){
let payInfo=this.payInfo;
uni.requestPayment({
provider: 'wxpay',
timeStamp: this.payInfo.timeStamp,
nonceStr: this.payInfo.nonceStr,
package: this.payInfo.package,
signType: this.payInfo.signType,
paySign: this.payInfo.sign,
success: function (res) {
console.log("success",res)
},
fail: function (err) {
console.log('fail:',err);
}
});
},
}
}
</script>
<style>
</style>
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