purchase-let/pageQuota/vipUser/index.vue

611 lines
16 KiB
Vue
Raw Normal View History

2024-06-17 08:38:39 +08:00
<template>
2024-06-17 17:16:09 +08:00
<view class="" v-if="!STORE_INFO.id">
2024-06-22 18:52:03 +08:00
<up-modal :show="showModa" title="门店信息" @confirm="confirmStore" confirmColor='#20B128'>
2024-06-17 17:16:09 +08:00
<view class="slot-content">
2024-06-22 18:52:03 +08:00
<up-form labelPosition="left" label-width="100rpx">
<up-form-item label="手机号" borderBottom>
<up-input v-model="storePhone" placeholder="请输入门店手机号"></up-input>
</up-form-item>
<up-form-item label="角色" borderBottom>
<uni-data-select v-model="Role" :localdata="range" :clear='false'></uni-data-select>
</up-form-item>
</up-form>
2024-06-17 17:16:09 +08:00
</view>
</up-modal>
2024-06-17 08:38:39 +08:00
</view>
2024-06-17 17:16:09 +08:00
<view v-else>
<view class="tabs">
2024-06-22 18:52:03 +08:00
<text @click="currentTab=1" :class="{actText:currentTab==1}">开通{{Role==1?'行业会员':'商户'}} </text>
2024-06-17 20:47:54 +08:00
<text @click="currentTab=2,getCount(),getLists()" :class="{actText:currentTab==2}"> 已开通列表</text>
2024-06-17 17:16:09 +08:00
<view class="lines" :class="{actLine:currentTab==2}" />
</view>
<!-- tabs1 -->
<block v-if='currentTab==1'>
<view class="card card1">
<view class="card1-tit">
2024-06-22 18:52:03 +08:00
{{Role==1?'行业会员':'商户'}}开通报备
2024-06-17 17:16:09 +08:00
</view>
<up-form labelPosition="left" :model="formData" :borderBottom='false'>
<up-form-item label="" prop="userInfo.name">
<up-input v-model="formData.real_name" border="none" prefixIcon="account" placeholder="请输入真实姓名"
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
:placeholderStyle="{color:'#444444'}"
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
</up-form-item>
<up-form-item label="" prop="userInfo.name">
2024-06-22 18:52:03 +08:00
<up-input v-model="formData.mobile" border="none" prefixIcon="phone" placeholder="请输入电话号码"
2024-06-17 17:16:09 +08:00
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
:placeholderStyle="{color:'#444444'}"
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
</up-form-item>
<up-form-item label="" prop="userInfo.name">
<view @click="showPop=true" style="width: 100%;">
<up-input style="pointer-events: none" v-model="formData.address" border="none"
2024-06-22 18:52:03 +08:00
prefixIcon="map" readonly placeholder="点击选择地址" :customStyle="{background:'#F3F3F3',padding:'20rpx',
'border-radius':'30rpx'
}" :placeholderStyle="{color:'#444444'}" :prefixIconStyle="{'margin-right':'40rpx'}"
suffixIcon='arrow-down'></up-input>
</view>
</up-form-item>
<up-form-item label="" prop="userInfo.name" v-if='Role==1'>
<view @click="showPop1=true" style="width: 100%;">
<up-input style="pointer-events: none" v-model="formData.label_name" border="none"
prefixIcon="man-add" readonly placeholder="点击选择用户身份" :customStyle="{background:'#F3F3F3',padding:'20rpx',
2024-06-17 17:16:09 +08:00
'border-radius':'30rpx'
}" :placeholderStyle="{color:'#444444'}" :prefixIconStyle="{'margin-right':'40rpx'}"
suffixIcon='arrow-down'></up-input>
</view>
</up-form-item>
2024-06-22 18:52:03 +08:00
2024-06-17 17:16:09 +08:00
</up-form>
<view class="store-info">
2024-06-17 20:47:54 +08:00
报备人:{{STORE_INFO.name}}
2024-06-17 17:16:09 +08:00
</view>
2024-06-17 08:38:39 +08:00
</view>
2024-06-17 20:47:54 +08:00
<view class="submit-btn" @click="submit">
<!-- <up-button text="完成并收款" size='large' :customStyle="{height:'100rpx',fontSize:'50rpx'}" @click="submit"
shape="circle" color="#50C758"></up-button> -->
<view
style='width: 710rpx;height: 100rpx;text-align: center;line-height: 100rpx;text-align: center;color: white;background-color: #33B83A;border-radius: 50rpx;font-size:40rpx ;'>
2024-06-22 18:52:03 +08:00
{{Role==1?'完成并收款':'完成'}}
2024-06-17 20:47:54 +08:00
</view>
2024-06-17 08:38:39 +08:00
</view>
2024-06-17 17:16:09 +08:00
</block>
<!-- tabs2 -->
<block v-else>
<view class="vip-card">
<text>当前已开通</text>
<up-count-to :startVal="0" :endVal="count"></up-count-to>
2024-06-22 18:52:03 +08:00
<text>{{Role==1?'行业会员':'商户'}}会员</text>
2024-06-17 17:16:09 +08:00
</view>
<view class="table">
<uni-table stripe emptyText="暂无更多数据" width="100%">
<!-- 表头行 -->
<uni-tr>
2024-06-17 18:47:06 +08:00
<uni-th width="20" align="center">序号</uni-th>
2024-06-22 18:52:03 +08:00
<uni-th width="50" align="center" v-if='Role==1'>行业会员</uni-th>
<uni-th width="50" align="center" v-if='Role==1'>经营资金</uni-th>
<uni-th width="50" align="center" v-if='Role==4'>开通时间</uni-th>
<uni-th width="50" align="center" v-if='Role==4'>商户</uni-th>
<uni-th width="50" align="center" v-if='Role==1'>角色</uni-th>
2024-06-17 18:47:06 +08:00
<uni-th width="50" align="center">状态</uni-th>
2024-06-17 17:16:09 +08:00
</uni-tr>
<!-- 表格数据行 -->
2024-06-18 10:19:49 +08:00
<uni-tr v-for="(item,index) in lists" :key="item.order_id">
2024-06-17 17:16:09 +08:00
<uni-td align="center">{{index+1}}</uni-td>
2024-06-22 18:52:03 +08:00
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.real_name}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.price}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==4'>{{item.create_time}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==4'>{{item.nickname}}</uni-td>
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.label_name}}</uni-td>
2024-06-17 17:16:09 +08:00
<uni-td style="font-size: 20rpx;" align="center">
2024-06-22 18:52:03 +08:00
<view v-if="item.paid ==1 ||Role==4">已开通</view>
2024-06-17 17:16:09 +08:00
<view v-else @click="upadtaStatus(item)" style="color:#33B83A ;">未开通,查询</view>
</uni-td>
</uni-tr>
</uni-table>
</view>
</block>
</view>
2024-06-17 08:38:39 +08:00
2024-06-17 15:29:52 +08:00
<!-- 地址选择器 -->
<up-popup :show="showPop" @close="showPop=false" @open="showPop=true" :round="10">
<view style="padding: 20rpx;">
<up-tabs :list="tabsList" @change='addressTbasChange' :current='currentAddressIndex' lineColor='#20B128'
:activeStyle="{color:'#20B128'}"></up-tabs>
<up-line style="margin-top:20rpx "></up-line>
<view class="address-content" v-if='currentAddressIndex==0'>
<view class="address-li" :class='{act:item.city_code==formData.city}' v-for="item in addressList.city"
2024-06-18 10:19:49 +08:00
:key="item.city_code" @click="addressLiClick(0, item)">
2024-06-17 15:29:52 +08:00
<text>{{item.city_name}}</text>
<up-icon name="arrow-right" :color="item.city_code==formData.city ?'#20B128':'#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==1'>
<view class="address-li" v-for="item in addressList.area" @click="addressLiClick(1,item)"
2024-06-18 10:19:49 +08:00
:key="item.area_code" :class='{act:item.area_code==formData.area}'>
2024-06-17 15:29:52 +08:00
<text>{{item.area_name}}</text>
<up-icon name="arrow-right" :color="item.area_code==formData.area ?'#20B128':'#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==2'>
<view class="address-li" v-for="item in addressList.street" @click="addressLiClick(2,item)"
2024-06-18 10:19:49 +08:00
:key="item.street_code" :class='{act:item.street_code==formData.street}'>
2024-06-17 15:29:52 +08:00
<text>{{item.street_name}}</text>
<up-icon name="arrow-right" :color="item.street_code==formData.street ?'#20B128':'#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==3'>
<view class="address-li" v-for="item in addressList.village" @click="addressLiClick(3,item)"
2024-06-18 10:19:49 +08:00
:key="item.village_code" :class='{act:item.village_code==formData.village}'>
2024-06-17 15:29:52 +08:00
<text>{{item.village_name}}</text>
<up-icon name="arrow-right" :color="item.village_code==formData.village ?'#20B128':'#777777'" />
</view>
</view>
<view class="address-content" v-else-if='currentAddressIndex==4'>
<view class="address-li" :class='{act:item.id==formData.brigade}' v-for="item in addressList.brigade"
2024-06-18 10:19:49 +08:00
:key="item.id" @click="addressLiClick(4,item)">
2024-06-17 15:29:52 +08:00
<text>{{item.brigade_name}}</text>
<up-icon name="arrow-right" :color="item.id==formData.brigade ?'#20B128':'#777777'" />
</view>
</view>
</view>
</up-popup>
2024-06-22 18:52:03 +08:00
<up-picker :show="showPop1" :columns="columns" @confirm='conformRole' @close="showPop1=false" @open="showPop1=true"
keyName='label_name' confirmColor='#33B83A'></up-picker>
2024-06-17 08:38:39 +08:00
</template>
<script setup>
import {
reactive,
ref
} from 'vue';
2024-06-17 15:29:52 +08:00
import {
provinceListApi,
cityListApi,
areaListApi,
streetListApi,
villageListApi,
brigadeListApi
} from "@/api/address.js"
import {
vipRechargeApi,
rechargeCountApi,
rechargeListsApi,
2024-06-17 17:16:09 +08:00
updataOrderApi,
2024-06-22 18:52:03 +08:00
getStoreByPhone,
getUserLabel,
getUserShip,
getCreateLists
2024-06-17 15:29:52 +08:00
} from "@/api/user.js"
import {
2024-06-22 18:52:03 +08:00
onPullDownRefresh,
onLoad
2024-06-17 15:29:52 +08:00
} from "@dcloudio/uni-app"
2024-06-17 08:38:39 +08:00
2024-06-22 18:52:03 +08:00
const showPop1 = ref(false)
const Role = ref('')
const range = ref({})
const columns = ref([])
2024-06-17 17:16:09 +08:00
const showModa = ref(true)
2024-06-18 10:15:10 +08:00
const storePhone = ref('')
2024-06-17 17:16:09 +08:00
const confirmStore = () => {
getStoreByPhone({
phone: storePhone.value
}).then(res => {
for (let key in res.data) {
STORE_INFO[key] = res.data[key]
}
2024-06-22 18:52:03 +08:00
setPhoneOneDay()
2024-06-17 17:16:09 +08:00
}).catch(err => {
uni.$u.toast('未查到店铺信息,请检查手机号码')
})
}
2024-06-17 08:38:39 +08:00
// 用户选择的门店信息
2024-06-17 17:16:09 +08:00
let STORE_INFO = reactive({
id: ""
})
2024-06-17 08:38:39 +08:00
2024-06-22 18:52:03 +08:00
const setPhoneOneDay = () => {
if (uni.getStorageSync('VIP_PHONE')) return;
const currentDate = new Date();
const nextDay = new Date(currentDate);
nextDay.setDate(currentDate.getDate() + 1);
uni.setStorageSync('VIP_PHONE', JSON.stringify({
time: nextDay,
phone: storePhone.value
}));
}
const getPhoneOneDay = () => {
if (uni.getStorageSync('VIP_PHONE')) {
let data = JSON.parse(uni.getStorageSync('VIP_PHONE'))
if (new Date() > data.time) {
uni.removeStorageSync('VIP_PHONE');
} else {
storePhone.value = data.phone
}
}
}
2024-06-17 08:38:39 +08:00
const currentTab = ref(1)
const formData = reactive({
2024-06-17 15:29:52 +08:00
store_id: STORE_INFO.id,
mobile: "",
province: 510000,
city: '',
area: "",
street: "",
village: "",
brigade: "",
real_name: "",
2024-06-17 18:47:06 +08:00
auth_code: "",
2024-06-22 18:52:03 +08:00
address: "",
label_name: "",
label_id: ""
2024-06-17 08:38:39 +08:00
})
2024-06-22 18:52:03 +08:00
const conformRole = (e) => {
formData.label_name = e.value[0].label_name
formData.label_id = e.value[0].label_id
showPop1.value = false
}
2024-06-17 08:38:39 +08:00
2024-06-17 15:29:52 +08:00
// 地址选择
const showPop = ref(false)
const currentAddressIndex = ref(0)
const currentAddressList = () => {
if (!formData.city) return [0, 'city'];
else if (formData.area) return [1, 'area'];
else if (formData.street) return [2, 'street'];
else if (formData.village) return [3, 'village'];
else if (formData.brigade) return [4, 'brigade'];
}
const addressTbasChange = (e) => {
currentAddressIndex.value = e.index
}
const addressList = reactive({
city: [],
area: [],
street: [],
village: [],
brigade: []
})
const addressLiClick = async (i, item) => {
if (i == 0) {
formData.city = item.city_code
tabsList[0].name = item.city_name
let res = await areaListApi({
city_code: formData.city
})
addressList.area = res.data
}
if (i == 1) {
formData.area = item.area_code
tabsList[1].name = item.area_name
let res = await streetListApi({
area_code: formData.area
})
addressList.street = res.data
}
if (i == 2) {
formData.street = item.street_code
tabsList[2].name = item.street_name
let res = await villageListApi({
street_code: formData.street
})
addressList.village = res.data
}
if (i == 3) {
formData.village = item.village_code
tabsList[3].name = item.village_name
let res = await brigadeListApi({
village_code: formData.village
})
addressList.brigade = res.data
}
if (i == 4) {
formData.brigade = item.id
tabsList[4].name = item.brigade_name
formData.address = tabsList[0].name + tabsList[1].name + tabsList[2].name + tabsList[3].name +
tabsList[4].name
return showPop.value = false
}
formData.address = tabsList[0].name + tabsList[1].name + tabsList[2].name + tabsList[3].name + tabsList[4]
.name
return currentAddressIndex.value++
}
const getCityList = async () => {
let res = await cityListApi({
province_code: formData.province
})
addressList.city = res.data
}
getCityList()
const tabsList = reactive(
[{
name: "请选择"
},
{
name: '请选择',
disabled: false
},
{
name: '请选择',
disabled: false
},
{
name: '请选择',
disabled: false
},
{
name: '请选择',
disabled: false
},
]);
const submit = async () => {
if (!formData.real_name) return uni.$u.toast('请填写真实姓名');
if (!formData.mobile) return uni.$u.toast('请填写电话号码');
2024-06-17 20:47:54 +08:00
formData.store_id = STORE_INFO.id
2024-06-22 18:52:03 +08:00
if (Role.value == 1) {
uni.scanCode({
success: function(res) {
formData.auth_code = res.result
formData.recharge_type = 'INDUSTRYMEMBERS'
vipRechargeApi(formData).then(res => {
uni.$u.toast('操作成功');
currentTab.value = 2
formData.real_name = ''
formData.mobile = ''
formData.address = ''
formData.label_name = ''
tabsList.forEach(item => {
item.name = '请选择'
})
2024-06-17 20:47:54 +08:00
2024-06-22 18:52:03 +08:00
})
getCount()
getLists()
}
});
} else {
delete formData.recharge_type
delete formData.auth_code
vipRechargeApi(formData).then(res => {
uni.$u.toast('操作成功');
currentTab.value = 2
formData.real_name = ''
formData.mobile = ''
formData.address = ''
formData.label_name = ''
tabsList.forEach(item => {
item.name = '请选择'
2024-06-17 15:29:52 +08:00
})
2024-06-17 18:47:06 +08:00
getLists()
2024-06-22 18:52:03 +08:00
getCount()
})
}
2024-06-17 08:38:39 +08:00
}
2024-06-17 15:29:52 +08:00
// 邀请用户数
const count = ref(0)
const getCount = async () => {
2024-06-22 18:52:03 +08:00
if (Role.value == 4) return;
2024-06-17 15:29:52 +08:00
let res = await rechargeCountApi({
store_id: STORE_INFO.id
})
count.value = res.data.count
}
// 邀请列表
const lists = ref([])
const getLists = async () => {
2024-06-22 18:52:03 +08:00
if (Role.value == 1) {
let res = await rechargeListsApi({
store_id: STORE_INFO.id,
recharge_type: "INDUSTRYMEMBERS"
})
lists.value = res.data.lists
} else {
let res = await getCreateLists({
store_id: STORE_INFO.id,
})
lists.value = res.data.lists
count.value = res.data.count
}
2024-06-17 15:29:52 +08:00
}
getCount()
getLists()
const upadtaStatus = (item) => {
updataOrderApi({
order_no: item.order_id,
recharge: 1
})
2024-06-17 08:38:39 +08:00
}
2024-06-17 15:29:52 +08:00
2024-06-22 18:52:03 +08:00
onLoad(() => {
getUserShip().then(res => {
console.log(res)
range.value = res.data.lists.map(item => {
return {
value: item.id,
text: item.title
}
})
})
getUserLabel().then(res => {
columns.value = [res.data.lists]
})
getPhoneOneDay()
})
2024-06-17 15:29:52 +08:00
onPullDownRefresh(() => {
getCount()
getLists()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 500)
})
2024-06-17 08:38:39 +08:00
</script>
<style lang='scss'>
.tabs {
background-color: #fff;
width: 100vw;
box-sizing: border-box;
padding: 30rpx 0;
justify-content: space-around;
position: relative;
display: flex;
font-size: 32rpx;
color: #444444;
.actText {
color: #20B128;
}
.lines {
position: absolute;
width: 70rpx;
height: 7rpx;
border-radius: 8rpx;
background-color: #33B83A;
bottom: 15rpx;
transition: 300ms;
left: calc(25vw - 35rpx);
}
.actLine {
left: calc(75vw - 35rpx);
}
}
.card {
width: 710rpx;
margin: 20rpx auto;
background-color: #fff;
box-sizing: border-box;
border-radius: 10rpx;
}
.card1 {
padding: 52rpx 30rpx;
.card1-tit {
font-size: 32rpx;
color: #444444;
text-align: center;
margin-bottom: 90rpx;
}
.store-info {
font-size: 28rpx;
color: #20B128;
text-align: center;
margin-top: 30rpx;
}
}
.submit-btn {
2024-06-17 20:47:54 +08:00
/* height: 200rpx; */
2024-06-17 08:38:39 +08:00
position: fixed;
bottom: 50rpx;
width: 710rpx;
left: 50%;
transform: translateX(-50%);
}
.vip-card {
width: 690rpx;
height: 270rpx;
background-image: url('https://lihai001.oss-cn-chengdu.aliyuncs.com/attach/4a92b202406162207212332.png');
background-size: 100% 100%;
margin: 20rpx auto;
display: flex;
align-items: center;
font-size: 30rpx;
box-sizing: border-box;
padding: 0 30rpx;
color: #444444;
justify-content: space-around;
.num {
font-size: 72rpx;
color: #7B5232;
}
}
.table {
width: 710rpx;
box-sizing: border-box;
font-size: 30rpx;
2024-06-17 15:29:52 +08:00
margin: 0 auto;
}
.address-content {
padding: 20rpx;
height: 50vh;
overflow-y: auto;
.address-li {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 32rpx;
color: #777777;
margin: 30rpx 0;
}
.act {
color: #20B128;
}
2024-06-17 08:38:39 +08:00
}
2024-06-17 18:47:06 +08:00
.uni-table-th {
padding: 10rpx 0 !important;
}
.uni-table-td {
padding: 10rpx 0 !important;
}
2024-06-22 18:52:03 +08:00
.slot-content {
padding-bottom: 50rpx;
}
2024-06-17 08:38:39 +08:00
</style>