726 lines
16 KiB
Vue
726 lines
16 KiB
Vue
<template>
|
||
<view class="user-index">
|
||
<view class="page-bg"></view>
|
||
<view class="header" :style="'margin-top: ' + statusBarHeight + 'px'"></view>
|
||
<view class="main-header">
|
||
<image class="bg-image" :src="bgImage" mode="scaleToFill"></image>
|
||
<!-- 用户信息 -->
|
||
</view>
|
||
|
||
<view class="main">
|
||
<!-- 表单信息 -->
|
||
<u--form :model="form" ref="uForm">
|
||
<view class="buy-user">
|
||
<!-- 表单组件 -->
|
||
<view class="form-wrapper">
|
||
<u-cell-group :border="false">
|
||
<u-cell title="姓名" :isLink="true">
|
||
<input slot="value" class="w-input" placeholder="请填写姓名" v-model="form.realName" />
|
||
</u-cell>
|
||
<u-cell title="手机号" :isLink="true">
|
||
<input slot="value" class="w-input" placeholder="请填写手机号码" v-model="form.phone" />
|
||
</u-cell>
|
||
<u-cell title="所属区域" :isLink="true" @click="onArea">
|
||
<input slot="value" class="w-input" placeholder="请选择所属区域" :disabled="true"
|
||
v-model="form.area" />
|
||
</u-cell>
|
||
<u-cell title="服务门店" :isLink="true" @click="onMerchant"
|
||
v-if="form.planId != 19 && form.planId != 22 && form.planId != 23 && form.planId != 24 && form.planId != 25 && form.planId != 26">
|
||
<input slot="value" class="w-input" :disabled="true" placeholder="请选择服务门店"
|
||
v-model="form.merchantName" />
|
||
</u-cell>
|
||
<u-cell title="门店地址" :isLink="true"
|
||
v-if="form.planId == 22 || form.planId == 23 || form.planId == 24 || form.planId == 25 || form.planId == 26">
|
||
<input slot="value" class="w-input" placeholder="请输入门店地址" v-model="form.address" />
|
||
</u-cell>
|
||
<u-cell title="门店类型" :border="false" :isLink="true" :value="form.name">
|
||
</u-cell>
|
||
</u-cell-group>
|
||
</view>
|
||
</view>
|
||
<u-gap height="3"></u-gap>
|
||
<!-- 会员套餐 -->
|
||
<view class="buy-user">
|
||
<u-cell :title="form.roleName"></u-cell>
|
||
<view class="price-box">
|
||
<view class="info">
|
||
<image :src="form.icon"
|
||
mode="aspectFill"></image>
|
||
<view class="content">
|
||
{{ form.name }}
|
||
</view>
|
||
</view>
|
||
<view class="price" v-for="(item,index) in form.price" :key="index">
|
||
<text class="reb">¥{{ item.price }}</text>
|
||
<text class="num">x1</text>
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
<view class="xieyi">
|
||
<u-icon name="checkbox-mark"></u-icon>
|
||
购买代表同意爱尚客网
|
||
<text>《婚介协议》</text>
|
||
</view>
|
||
</u--form>
|
||
</view>
|
||
<view class="cart">
|
||
<view class="cart-info">
|
||
<!-- <view style="position: relative;"> -->
|
||
<!-- <u-badge class="badge" size="mini" type="error" :is-center="true" :count="totalNum"></u-badge> -->
|
||
<!-- <image class="cart-logo" src="../../static/icon/cart4.png"></image> -->
|
||
<!-- </view> -->
|
||
<view class="total-price">¥{{ totalPrice }}</view>
|
||
<!-- <view class="clear-cart" @click="onClearCart">清空购物车</view> -->
|
||
<view class="buy">
|
||
<u-button text="立即下单" shape="circle" type="error" class="custom-style" :disabled="disabled"
|
||
@click="onBuy">
|
||
</u-button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 地址选择器 -->
|
||
<liu-customize-sel ref="area" @change="chooseSuccess"></liu-customize-sel>
|
||
<!-- 选择店铺 -->
|
||
<u-picker :show="showMerchant" :columns="merchantList" keyName="label" @confirm="confirmMerchant"
|
||
@cancel="showMerchant = false"></u-picker>
|
||
</view>
|
||
|
||
</template>
|
||
|
||
<script>
|
||
import store from '@/store/index.js'
|
||
import storage from '@/utils/storage'
|
||
import * as UserPlanApi from '@/api/love-user-plan.js'
|
||
import * as UserPlanLogApi from '@/api/love-user-plan-log.js'
|
||
import * as MerchantApi from '@/api/merchant.js'
|
||
import {
|
||
getUser
|
||
} from '@/api/user.js'
|
||
import {
|
||
username
|
||
} from '@/config.js';
|
||
import http from '@/api'
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
merchantList: [],
|
||
bgImage: 'data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(6.123233995736766e-17%2C%201%2C%20-0.36308349769888226%2C%206.123233995736766e-17%2C%200.5%2C%200)%22%3E%3Cstop%20stop-color%3D%22%23101010%22%20stop-opacity%3D%221%22%20offset%3D%220.24%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23160028%22%20stop-opacity%3D%221%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E',
|
||
statusBarHeight: 25,
|
||
// 是否已登录
|
||
isLogin: false,
|
||
disabled: false,
|
||
showMerchant: false,
|
||
// 系统设置
|
||
form: {
|
||
area: '',
|
||
planId: 0,
|
||
priceId: 0,
|
||
province: '',
|
||
city: '',
|
||
region: ''
|
||
},
|
||
subPayPrice: 0,
|
||
city: '',
|
||
rules: [],
|
||
totalPrice: 0.00
|
||
}
|
||
},
|
||
onLoad(options) {
|
||
console.log("options: ", options);
|
||
this.form.planId = Number(options.planId)
|
||
this.subPayPrice = options.subPayPrice
|
||
this.getUserInfo()
|
||
this.getOrderInfo()
|
||
// 设置navbar标题、颜色options
|
||
uni.setNavigationBarColor({
|
||
frontColor: '#ffffff',
|
||
backgroundColor: '#101010'
|
||
})
|
||
},
|
||
onShow() {},
|
||
|
||
// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
|
||
onReady() {
|
||
this.$refs.uForm.setRules(this.rules)
|
||
},
|
||
methods: {
|
||
// 跳转页面
|
||
navTo(url) {
|
||
this.$navTo(url)
|
||
},
|
||
getUserInfo() {
|
||
const {
|
||
form
|
||
} = this
|
||
const app = this
|
||
uni.getSystemInfo({
|
||
success(data) {
|
||
if (data) {
|
||
app.statusBarHeight = data.statusBarHeight + 50
|
||
}
|
||
}
|
||
})
|
||
getUser().then(res => {
|
||
if (res.code == 0 && res.data.username != 'www') {
|
||
if (res.data) {
|
||
console.log("res.data.phone: ", res.data.phone);
|
||
app.form.realName = res.data.nickname
|
||
app.form.phone = res.data.phone
|
||
}
|
||
app.isLogin = true
|
||
} else {
|
||
app.isLogin = false
|
||
app.$push('pages/login/index')
|
||
}
|
||
})
|
||
|
||
},
|
||
getOrderInfo() {
|
||
const app = this
|
||
const {
|
||
planId
|
||
} = this.form
|
||
UserPlanApi.getUserPlan(planId).then(result => {
|
||
console.log("result: ", result);
|
||
app.form = result.data
|
||
result.data.price.map(d => {
|
||
app.form.priceId = d.id
|
||
app.totalPrice = (d.price-app.subPayPrice).toFixed(2)
|
||
})
|
||
})
|
||
},
|
||
getMerchant() {
|
||
const app = this
|
||
MerchantApi.listMerchant({
|
||
region: app.form.region
|
||
}).then(result => {
|
||
let arr = []
|
||
app.merchantList = []
|
||
result.data.map(d => {
|
||
arr.push({
|
||
id: d.merchantId,
|
||
label: `${d.merchantName} (${d.gradeName})`,
|
||
code: d.merchantCode
|
||
})
|
||
})
|
||
console.log("arr: ",arr);
|
||
app.merchantList.push(arr)
|
||
})
|
||
|
||
},
|
||
onArea() {
|
||
this.$refs.area.open()
|
||
},
|
||
onMerchant() {
|
||
this.showMerchant = true
|
||
},
|
||
confirmMerchant(e) {
|
||
const data = e.value[0]
|
||
this.form.merchantId = Number(data.id)
|
||
this.form.merchantCode = data.code
|
||
this.form.merchantName = data.label
|
||
this.showMerchant = false
|
||
},
|
||
//地址选择成功
|
||
chooseSuccess(e) {
|
||
const app = this
|
||
const data = e.value
|
||
app.city = data[1].label
|
||
app.form.area = `${data[0].label} ${data[1].label} ${data[2].label}`
|
||
app.form.province = data[0].label
|
||
app.form.city = data[1].label
|
||
app.form.region = data[2].label
|
||
app.form.merchantName = null
|
||
app.form.merchantId = null
|
||
app.getMerchant()
|
||
},
|
||
onBuy() {
|
||
const app = this
|
||
const {
|
||
form,
|
||
totalPrice
|
||
} = this
|
||
if (form.realName == '') {
|
||
this.$error('请填写姓名')
|
||
return false
|
||
}
|
||
if (form.phone == '') {
|
||
this.$error('请填写手机号码')
|
||
return false
|
||
}
|
||
if (!form.area) {
|
||
this.$error('请选择所属区域')
|
||
return false
|
||
}
|
||
if (!form.merchantId && form.planId != 19 && form.planId != 22 && form.planId != 23 && form.planId !=
|
||
24 && form.planId != 25 && form.planId != 26) {
|
||
this.$error('请选择服务门店')
|
||
return false
|
||
}
|
||
app.disabled = true
|
||
UserPlanLogApi.addUserPlanLog({
|
||
planId: form.planId,
|
||
priceId: form.priceId,
|
||
province: form.province,
|
||
city: form.city,
|
||
region: form.region,
|
||
area: form.area,
|
||
realName: form.realName,
|
||
phone: form.phone,
|
||
merchantId: form.merchantId,
|
||
merchantCode: form.merchantCode,
|
||
merchantName: form.merchantName,
|
||
address: form.address,
|
||
totalPrice
|
||
}).then(res => {
|
||
const orderInfo = res.data
|
||
|
||
if(orderInfo == null){
|
||
// 业务逻辑。。。
|
||
uni.showModal({
|
||
title: '支付成功',
|
||
content: '如果状态没更新,请尝试下拉更新',
|
||
showCancel: false,
|
||
success: function(res) {
|
||
if (res.confirm) {
|
||
app.showEdit = false
|
||
app.disabled = false
|
||
uni.navigateBack({
|
||
delta: 2
|
||
})
|
||
}
|
||
}
|
||
})
|
||
return false
|
||
}
|
||
// 调起微信支付
|
||
uni.requestPayment({
|
||
provider: orderInfo.provider, // 服务提供商
|
||
timeStamp: orderInfo.timeStamp, // 时间戳
|
||
nonceStr: orderInfo.nonceStr, // 随机字符串
|
||
package: orderInfo.package,
|
||
signType: orderInfo.signType, // 签名算法
|
||
paySign: orderInfo.paySign, // 签名
|
||
success: function(res) {
|
||
// 业务逻辑。。。
|
||
uni.showModal({
|
||
title: '支付成功',
|
||
content: '如果状态没更新,请尝试下拉更新',
|
||
showCancel: false,
|
||
success: function(res) {
|
||
if (res.confirm) {
|
||
app.showEdit = false
|
||
app.disabled = false
|
||
uni.navigateBack({
|
||
delta: 2
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
fail: function(err) {
|
||
console.log('支付失败', err);
|
||
app.disabled = false
|
||
}
|
||
});
|
||
}).catch(err => {
|
||
app.disabled = false
|
||
})
|
||
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.user-index {
|
||
background-color: #f3f3f3;
|
||
height: 100vh;
|
||
}
|
||
|
||
.container {
|
||
padding-bottom: 60rpx;
|
||
}
|
||
|
||
.page-bg {
|
||
width: 750rpx;
|
||
height: calc(100rpx + var(--status-bar-height));
|
||
display: block;
|
||
background-color: #101010;
|
||
position: absolute;
|
||
left: 0;
|
||
top: 0;
|
||
z-index: -100;
|
||
}
|
||
|
||
// 页面头部
|
||
.main-header {
|
||
// background-color: #FBF7EF;
|
||
position: fixed;
|
||
top: 0;
|
||
width: 100%;
|
||
height: 360rpx;
|
||
background-size: 100% 100%;
|
||
overflow: hidden;
|
||
display: flex;
|
||
align-items: center;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
|
||
.bg-image {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
z-index: 0;
|
||
}
|
||
|
||
.star {
|
||
position: absolute;
|
||
opacity: 0.1;
|
||
color: #fff;
|
||
}
|
||
|
||
.star1 {
|
||
width: 100rpx;
|
||
height: 100rpx;
|
||
right: 80rpx;
|
||
top: 34rpx;
|
||
}
|
||
|
||
.star2 {
|
||
width: 100rpx;
|
||
height: 100rpx;
|
||
left: 40rpx;
|
||
top: 10rpx;
|
||
}
|
||
|
||
.star3 {
|
||
width: 70rpx;
|
||
height: 70rpx;
|
||
left: 130rpx;
|
||
top: 70rpx;
|
||
}
|
||
|
||
|
||
.user-info {
|
||
display: flex;
|
||
height: 120rpx;
|
||
padding-left: 30rpx;
|
||
z-index: 1;
|
||
|
||
.user-content {
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
margin-left: 30rpx;
|
||
color: #ffffff;
|
||
|
||
.nick-name {
|
||
font-size: 30rpx;
|
||
font-weight: bold;
|
||
max-width: 270rpx;
|
||
display: flex;
|
||
flex-direction: row;
|
||
|
||
image {
|
||
margin-left: 10rpx;
|
||
width: 36rpx;
|
||
height: 36rpx;
|
||
}
|
||
}
|
||
|
||
.user-id {
|
||
font-weight: 300;
|
||
color: #efefef;
|
||
font-size: 24rpx;
|
||
}
|
||
|
||
.mobile {
|
||
margin-top: 15rpx;
|
||
font-size: 28rpx;
|
||
}
|
||
|
||
.user-grade {
|
||
align-self: baseline;
|
||
display: flex;
|
||
align-items: center;
|
||
background: #3c3c3c;
|
||
margin-top: 12rpx;
|
||
border-radius: 10rpx;
|
||
padding: 4rpx 12rpx;
|
||
|
||
.user-grade_icon .image {
|
||
display: block;
|
||
width: 32rpx;
|
||
height: 32rpx;
|
||
}
|
||
|
||
.user-grade_name {
|
||
margin-left: 5rpx;
|
||
font-size: 26rpx;
|
||
color: #EEE0C3;
|
||
}
|
||
|
||
}
|
||
|
||
.roles-box {
|
||
display: flex;
|
||
|
||
.login-tips {
|
||
margin-top: 12rpx;
|
||
margin-right: 6rpx;
|
||
font-size: 30rpx;
|
||
display: flex;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
|
||
.switch {
|
||
display: flex;
|
||
color: #ffffff;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
align-items: center;
|
||
padding-right: 50rpx;
|
||
z-index: 999;
|
||
|
||
image {
|
||
width: 45rpx;
|
||
height: 45rpx;
|
||
}
|
||
|
||
.switch-text {
|
||
z-index: 9999;
|
||
color: #681752;
|
||
}
|
||
}
|
||
|
||
.setting {
|
||
color: #cecece;
|
||
position: absolute;
|
||
right: 2vh;
|
||
top: 1vh;
|
||
|
||
image {
|
||
width: 45rpx;
|
||
height: 45rpx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.main {
|
||
position: fixed;
|
||
top: 80rpx;
|
||
left: 25rpx;
|
||
z-index: 999;
|
||
|
||
// 开通会员
|
||
.buy-user {
|
||
display: flex;
|
||
flex-direction: column;
|
||
margin: 22rpx auto 22rpx auto;
|
||
padding: 22rpx 0;
|
||
width: 700rpx;
|
||
box-shadow: 0 1rpx 5rpx 0px #eaebec;
|
||
border-radius: 24rpx;
|
||
background: #fff;
|
||
|
||
.desc {
|
||
padding-top: 5rpx;
|
||
padding-left: 32rpx;
|
||
font-size: 28rpx;
|
||
color: #545454;
|
||
}
|
||
|
||
.asset-right {
|
||
width: 170rpx;
|
||
border-left: 1rpx solid #eee;
|
||
}
|
||
|
||
.asset-right-item {
|
||
text-align: center;
|
||
color: #545454;
|
||
|
||
.item-icon {
|
||
font-size: 44rpx;
|
||
}
|
||
|
||
.item-name {
|
||
margin-top: 14rpx;
|
||
font-size: 28rpx;
|
||
}
|
||
}
|
||
|
||
.asset-left-item {
|
||
text-align: center;
|
||
padding-left: 28rpx;
|
||
display: flex;
|
||
|
||
.item-value {
|
||
font-size: 34rpx;
|
||
// color: #febd45;
|
||
}
|
||
|
||
.item-name {
|
||
color: #545454;
|
||
margin-top: 14rpx;
|
||
font-size: 24rpx;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
flex-direction: column;
|
||
margin: 30rpx 25rpx 20rpx 0;
|
||
}
|
||
|
||
.buy-user-icon {
|
||
width: 40rpx;
|
||
margin-bottom: 8rpx;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
// 退出登录
|
||
.my-logout {
|
||
display: flex;
|
||
justify-content: center;
|
||
margin-top: 50rpx;
|
||
|
||
.logout-btn {
|
||
width: 400rpx;
|
||
margin: 0 auto;
|
||
font-size: 28rpx;
|
||
color: #616161;
|
||
border-radius: 20rpx;
|
||
border: 1px solid #dcdcdc;
|
||
padding: 16rpx 0;
|
||
text-align: center;
|
||
}
|
||
}
|
||
|
||
.price-box {
|
||
padding: 30rpx;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
|
||
.info {
|
||
display: flex;
|
||
|
||
image {
|
||
width: 120rpx;
|
||
height: 120rpx;
|
||
border-radius: 20rpx;
|
||
}
|
||
|
||
.content {
|
||
width: 280rpx;
|
||
padding-left: 30rpx;
|
||
font-size: 28rpx;
|
||
color: #666666;
|
||
}
|
||
}
|
||
|
||
.price {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-end;
|
||
padding: 0 20rpx;
|
||
|
||
.reb {
|
||
color: #ff0000;
|
||
}
|
||
|
||
.num {
|
||
color: #999999;
|
||
}
|
||
}
|
||
}
|
||
|
||
.xieyi {
|
||
width: 500rpx;
|
||
font-size: 26rpx;
|
||
text-align: center;
|
||
display: flex;
|
||
margin: 50rpx auto;
|
||
color: #999999;
|
||
|
||
text {
|
||
text-decoration: underline;
|
||
color: #681752;
|
||
}
|
||
}
|
||
|
||
.cart {
|
||
position: fixed;
|
||
bottom: 25rpx;
|
||
z-index: 888;
|
||
width: 750rpx;
|
||
height: 80rpx;
|
||
line-height: 80rpx;
|
||
|
||
.cart-info {
|
||
background: linear-gradient(to bottom, $main-bg, $main-bg2);
|
||
width: 700rpx;
|
||
margin: auto;
|
||
display: flex;
|
||
border-radius: 100rpx;
|
||
justify-content: space-between;
|
||
position: relative;
|
||
|
||
.cart-logo {
|
||
position: absolute;
|
||
width: 90rpx;
|
||
height: 90rpx;
|
||
margin-left: 20rpx;
|
||
bottom: 10rpx;
|
||
}
|
||
|
||
.total-price {
|
||
padding-left: 30rpx;
|
||
font-size: 34rpx;
|
||
font-weight: bold;
|
||
color: #ffffff;
|
||
}
|
||
|
||
.clear-cart {
|
||
color: #ff0000;
|
||
}
|
||
|
||
.buy {
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
|
||
.custom-style {
|
||
padding: 0 50rpx;
|
||
color: #ffffff;
|
||
background-color: #ff0000;
|
||
// background: linear-gradient(to bottom, $main-bg, $main-bg2);
|
||
// background-color: #681752;
|
||
border: none;
|
||
width: 330rpx;
|
||
height: 66rpx;
|
||
font-size: 28rpx;
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
.w-input {
|
||
width: 400rpx;
|
||
text-align: right;
|
||
font-size: 25rpx;
|
||
color: #606266;
|
||
}
|
||
</style>
|