Browse Source

Merge branch 'zzx' into 2.0

wenjie 7 months ago
parent
commit
642275b92e

+ 18 - 0
api/vipActivation.js

@@ -0,0 +1,18 @@
+import {request} from '@/utils/request.js'
+
+// 激活码兑换
+export function selectActivationCode(data) {
+	return request({
+		url: `/vipserver/group/user/activation?phone=${data.phoneNum}&serialNumber=${data.activationCode}`,
+		method: 'post',
+	})
+}
+
+//获取激活列表
+export function getActivationList(data) {
+	return request({
+		url: '/vipserver/group/user/activationList',
+		method: 'post',
+		data
+	})
+}

+ 268 - 0
my/vipActivation/index.vue

@@ -0,0 +1,268 @@
+<template>
+	<view class="vip">
+		<view style="height: 20rpx;"></view>
+		<view class="topCard">
+			<view class="vipInfo">
+				<view class="left">
+					<view class="ownVip">当前会员:<text>{{setMealName||'普通用户'}}</text></view>
+					<view class="endTime">会员到期时间: {{expireTime||'--'}}</view>
+				</view>
+				<view class="right">
+					<image slot="icon" src="../../static/vipTypology-icon.png" mode="widthFix"></image>
+				</view>
+			</view>
+			<view class="inputBox">
+				<input type="text" v-model="vipQuery.activationCode" placeholder="请输入激活码" placeholder-class="activationIpt" />
+				<u-button type="error " :loading="redeemload" loadingSize="20" shape="circle" text="立即兑换"
+					@click="confirmActivation"></u-button>
+			</view>
+		</view>
+		<view class="listCard">
+			<view class="listTitle">激活记录</view>
+			<view class="listBox" v-if="activationList.length>0">
+				<view class="list" v-for="(item,index) in activationList" :key="item.id">
+					<view class="vipTitle">
+						<view class="">{{item.planningName}}</view>
+						<view class="">已激活</view>
+					</view>
+					<view class="listInfo">
+						<view class="">激活码:<text>{{item.serialNumber}}</text></view>
+						<view class="">激活时间: {{item.useTime}}</view>
+					</view>
+				</view>
+			</view>
+			<block v-else>
+				<u-empty mode="data" textSize="20" iconSize="120" text="暂无激活记录"></u-empty>
+			</block>
+		</view>
+	</view>
+</template>
+
+<script>
+	import {mealList} from '@/api/combo.js'
+	import {refreshVip} from '@/api/common.js'
+	import { selectActivationCode,getActivationList } from '@/api/vipActivation.js'
+	import { levelImgName } from '@/utils/config.js'
+	import{parseDate} from '@/utils/tool.js'
+	export default {
+		data() {
+			return {
+				expireTime:'',
+				redeemload: false,
+				activationList: [],
+				list:[],
+				userInfo:'',
+				setMealName:'',
+				vipQuery:{
+					phoneNum:'',
+					activationCode:'',
+				}
+			}
+		},
+		onShow() {
+		},
+		onLoad() {
+			this.userInfo=JSON.parse(uni.getStorageSync('userInfo'))
+			this.vipQuery.phoneNum=this.userInfo.phoneNum
+			this.mealList()
+			this.get_activationList()
+			this.get_userinfo()
+		},
+
+		methods: {
+			// 用户信息
+			get_userinfo(){
+				refreshVip().then(res=>{
+					res.content.map((item)=>{
+						this.expireTime=parseDate(item.expirationTime, '{y}-{m}-{d} {h}:{m}:{s}' )
+					})
+				})
+			},
+			
+			// 激活列表
+			get_activationList(){
+				getActivationList().then(res=>{
+					if(res.state=='Success'){
+						res.content.content.map((item)=>{
+							item.useTime= parseDate(item.useTime,'{y}-{m}-{d} {h}:{m}:{s}')
+						})
+						this.activationList=res.content.content
+					}
+				})
+			},
+			
+			// 二次确认
+			confirmActivation() {
+				let that = this
+				uni.showModal({
+					title: '提示',
+					content: '确认兑换当前激活码吗?',
+					success(res) {
+						if (res.confirm) {
+							that.redeemload = true
+							that.select_activationCode()
+						}
+					}
+				})
+			},
+			
+			// 兑换激活码
+			select_activationCode(){
+				selectActivationCode(this.vipQuery).then(res=>{
+					this.redeemload=false
+					if(res.state=='Success'){
+						uni.showToast({
+							title: '激活成功',
+						});
+						this.vipQuery.activationCode=''
+						this.get_activationList()
+					}else{
+						uni.showToast({
+							title: res.content,
+						});
+					}
+				})
+			},
+
+			// 获取套餐类型
+			mealList(){
+				mealList({currentPage:1,pageSize:99,status:1}).then(res=>{
+					if (res.state == 'Success') {
+						this.list = res.content.records
+						// 判断当前会员类型
+						this.list.map(item=>{
+							if(item.setMealCode == this.userInfo.setMealCode){
+								this.setMealName = item.setMealName
+							}
+						})
+					}
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss">
+	.vip {
+		height: 100vh;
+		padding: 0 24rpx;
+		background: #F9F9F9;
+
+		.topCard {
+			background: #fff;
+			border-radius: 8rpx;
+			padding: 20rpx;
+
+			.vipInfo {
+				display: flex;
+				align-items: center;
+				justify-content: space-between;
+
+				.left {
+					.ownVip {
+						font-size: 28rpx;
+						color: #181818;
+						font-weight: bold;
+
+						&>text {
+							margin-left: 10rpx;
+							font-weight: bold;
+							font-size: 36rpx;
+						}
+					}
+
+					.endTime {
+						margin-top: 20rpx;
+						font-weight: normal;
+						font-size: 24rpx;
+						color: #AAAAAA;
+					}
+				}
+
+				.right {
+					&>image {
+						width: 100rpx;
+					}
+				}
+			}
+
+			.inputBox {
+				display: flex;
+				align-items: center;
+				border: #F9F9F9 4rpx solid;
+				border-radius: 50rpx;
+				padding: 6rpx;
+				margin-top: 20rpx;
+
+				&>input {
+					margin-left: 8rpx;
+					width: 1800rpx;
+				}
+
+				.activationIpt {
+					font-size: 28rpx;
+					color: #AAAAAA;
+				}
+			}
+		}
+
+		.listCard {
+			background: #fff;
+			border-radius: 8rpx;
+			padding: 20rpx;
+			margin-top: 20rpx;
+
+			.listTitle {
+				font-weight: bold;
+				font-size: 28rpx;
+				color: #222222;
+			}
+
+			.listBox {
+				.list {
+					border-bottom: 1rpx solid #F0F0F0;
+
+					.vipTitle {
+						display: flex;
+						align-items: center;
+						justify-content: space-between;
+						font-weight: bold;
+						font-size: 32rpx;
+						margin-top: 20rpx;
+
+						&>view:first-child {
+							color: #222222;
+						}
+
+						&>view:last-child {
+							color: #FF4A39;
+						}
+					}
+
+					.listInfo {
+						margin-top: 20rpx;
+
+						&>view:first-child {
+							font-weight: normal;
+							color: #222222;
+							font-size: 24rpx;
+
+							&>text {
+								margin-left: 10rpx;
+								color: #AAAAAA;
+							}
+						}
+
+						&>view:last-child {
+							height: 64rpx;
+							line-height: 64rpx;
+							font-size: 24rpx;
+							font-weight: normal;
+							color: #222222;
+						}
+					}
+				}
+			}
+		}
+	}
+</style>

+ 3 - 1
package-lock.json

@@ -1,6 +1,8 @@
 {
-  "requires": true,
+  "name": "双向滑动条",
+  "version": "v1.1.0",
   "lockfileVersion": 1,
+  "requires": true,
   "dependencies": {
     "address": {
       "version": "1.2.2",

+ 1 - 1
package.json

@@ -8,4 +8,4 @@
         "双向滑动条",
         "slider"
     ]
-}
+}

+ 12 - 0
pages.json

@@ -309,6 +309,12 @@
 					"style": {
 						"navigationBarTitleText": "客服"
 					}
+				},
+				{
+					"path": "vipActivation/index",
+					"style": {
+						"navigationBarTitleText": "会员激活"
+					}
 				}
 			]
 		},
@@ -643,6 +649,12 @@
 					"style": {
 						"navigationBarTitleText": "领券"
 					}
+				},
+				{
+					"path": "kaihui",
+					"style": {
+						"navigationBarTitleText": "凯辉便利"
+					}
 				}
 				
 			]

+ 3 - 0
pages/my/index.vue

@@ -86,6 +86,9 @@
 		<!-- 	<u-cell title="研学MBTI测试"  @click="jump('../../study/test')" :border="false" :isLink="true" arrow-direction="right">
 				<image slot="icon" class="cell-icon" src="../../static/icon8.png" mode=""></image>
 			</u-cell> -->
+			<u-cell title="会员激活"  @click="jump('../../my/vipActivation/index')" :border="false" :isLink="true" arrow-direction="right">
+				<image slot="icon" class="cell-icon" src="../../static/vip-icon.png" mode=""></image>
+			</u-cell>
 			<u-cell title="设置"  @click="jump('../../my/edit/edit')" :border="false" :isLink="true" arrow-direction="right">
 				<image slot="icon" class="cell-icon" src="../../static/setting-icon.png" mode=""></image>
 			</u-cell>

+ 129 - 0
special/kaihui.vue

@@ -0,0 +1,129 @@
+<template>
+	<view class="kaihuiLink">
+		<view class="imgBox">
+			<image src="../static/kaihui.png" mode="widthFix"></image>
+		</view>
+		<view class="btn">
+			<view class="kaihuiBtn" @click="handleBtn">立即下单</view>
+		</view>
+		<view class="kaihuiRule">
+			<view class="title">
+				<image src="../static/kaihuifuli.png" mode="widthFix"></image>
+			</view>
+			<view class="text">*仅限本平台会员中国移动用户专享</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import {
+		qrcode
+	} from '@/api/common.js';
+	export default {
+		data() {
+			return {
+				showWeb: false,
+				src: '',
+				test: ''
+			}
+		},
+		methods: {
+			handleBtn() {
+				if(uni.getStorageSync('token')){
+					if(JSON.parse(uni.getStorageSync('userInfo')).setMealCode != 0&&JSON.parse(uni.getStorageSync('userInfo')).setMealCode){
+						uni.navigateToMiniProgram({
+							appId:'wx57a08b407511613d',
+							path:'//凯辉/首页/YWUe2IrfXEryMkw'
+						})
+					}else{
+						uni.showModal({
+							title:'此权益需要开通会员才可使用',
+							cancelText:'下次再说',
+							confirmText:'立即开通',
+							success(res) {
+								if(res.confirm){
+									uni.navigateTo({
+										url:'/my/memberCenter/index'
+									})
+								}
+							}
+						})
+					}
+					
+				}else{
+					return uni.showModal({
+						title:'请登录',
+						confirmText:'去登录',
+						success(res){
+							if(res.confirm){
+								uni.navigateTo({
+									url:'/login/login/login?redirect=/special/water'
+								})
+							}
+						}
+					})
+				}
+				
+			},
+			loadedPage(){
+				uni.hideLoading()
+			},
+			onmessage(val){
+				console.log(val);
+			}
+		},
+		 created() {},
+	}
+</script>
+
+<style lang="scss" scoped>
+	.kaihuiLink {
+		.imgBox {
+			&>image {
+				width: 100%;
+			}
+		}
+
+		.btn {
+			width: 100%;
+			display: flex;
+			align-items: center;
+			justify-content: center;
+			position: relative;
+
+			.kaihuiBtn {
+				position: absolute;
+				width: 360rpx;
+				height: 80rpx;
+				border-radius: 40rpx;
+				background-color: #EE4320;
+				color: white;
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				font-size: 32rpx;
+				font-weight: bold;
+			}
+		}
+
+		.kaihuiRule {
+			margin-top: 60rpx;
+			width: 100%;
+			position: relative;
+			.title{
+				position: absolute;
+				left:200rpx;
+				&>image{
+					width: 350rpx;
+				}
+			}
+			.text{
+				position: absolute;
+				top: 40rpx;
+				font-size: 24rpx;
+				margin-top: 20rpx;
+				margin-left: 20rpx;
+			}
+		}
+	}
+</style>

BIN
static/kaihui.png


BIN
static/kaihuifuli.png


BIN
static/vip-icon.png


BIN
static/vipTypology-icon.png


+ 36 - 0
utils/tool.js

@@ -11,6 +11,42 @@ export function debounce(fn,delay=500) {
   };
 }
 
+// 时间戳转换
+export function parseDate(time, cFormat) {
+  if (arguments.length === 0) {
+    return null
+  }
+  const format = cFormat || '{y}-{m}-{d}'
+  let date
+  if (typeof time === 'object') {
+    date = time
+  } else {
+    if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
+      time = parseInt(time)
+    }
+    if ((typeof time === 'number') && (time.toString().length === 10)) {
+      time = time * 1000
+    }
+    date = new Date(time)
+  }
+  const formatObj = {
+    y: date.getFullYear(),
+    m: date.getMonth() + 1,
+    d: date.getDate(),
+    h: date.getHours(),
+    i: date.getMinutes(),
+    s: date.getSeconds(),
+    a: date.getDay()
+  }
+  const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
+    const value = formatObj[key]
+    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
+    return value.toString().padStart(2, '0')
+  })
+  return time_str
+}
+
+
 // 返回两个经纬度之间的距离 单位米
 const earthDistance = function (location1, location2) {
 	    const lat1 = parseFloat(location1.lat);