增加绑定微信功能界面,增加每日解锁支付超过最大获取抽奖次数时弹窗提醒,增加视频解锁创建订单提示未绑定微信407状态时跳转绑定微信界面

This commit is contained in:
YeMingfei666 2025-03-27 18:09:21 +08:00
parent b24bc98e1c
commit a859805009
11 changed files with 718 additions and 360 deletions

View File

@ -2,7 +2,7 @@
"version" : "1.0", "version" : "1.0",
"configurations" : [ "configurations" : [
{ {
"playground" : "standard", "playground" : "custom",
"type" : "uni-app:app-android" "type" : "uni-app:app-android"
}, },
{ {

View File

@ -54,3 +54,22 @@ export const bind = (data) => {
} }
/**
* 绑定微信
*/
export const $bindWx = (data) => {
return http.request({
url: 'Login/bindWx',
method: 'POST',
data: data
})
}
// 绑定微信状态
export const $bindStatus = (data) => {
return http.request({
url: 'Login/bindStatus',
method: 'GET',
data: data
})
}

View File

@ -4,39 +4,29 @@
<cell v-for="(item,index) in list" :key="item.courseDetailsId" :ref="setRefList(index)"> <cell v-for="(item,index) in list" :key="item.courseDetailsId" :ref="setRefList(index)">
<view class="swipers-items" :style="boxStyle" @longpress="popupShow('speed')"> <view class="swipers-items" :style="boxStyle" @longpress="popupShow('speed')">
<list-item-vue :total="list.length" :item="item" :current="current" :isCollect="isCollect" <list-item-vue :total="list.length" :item="item" :current="current" :isCollect="isCollect"
:isAndriod="isAndriod" :isAndriod="isAndriod" :showAndriod="showAndriod" :isIos="isIos" :isH5="isH5" :isTabbar="isTabbar"
:showAndriod="showAndriod" @playStatusChange="playStatusChange" :height="wHeight" :isCommand="isCommand"
:isIos="isIos" :showControls="control.showControls" @toDetail="toDetail(item,index)" @itemMounted="itemMounted"
:isH5="isH5" @controlstoggles="controlstoggles" :index="index" :instance="instance" :nowIndex="nowIndex"
:isTabbar="isTabbar" @playStatusChange="playStatusChange" :height="wHeight" @appear="appear($event,item,index)" :playSpeeds="playSpeeds"
:isCommand="isCommand" :showControls="control.showControls" @toDetail="toDetail(item,index)"
@itemMounted="itemMounted" @controlstoggles="controlstoggles" :index="index" :instance="instance"
:nowIndex="nowIndex" @appear="appear($event,item,index)" :playSpeeds="playSpeeds"
@disappear="disappear($event, item,index)" @dianzanClick="dianzanClick(item,index)" @disappear="disappear($event, item,index)" @dianzanClick="dianzanClick(item,index)"
@share="share(item)" @zhuijuClick="zhuijuClick(item)" @share="share(item)" @zhuijuClick="zhuijuClick(item)" @progressScroll="progressScroll"
@progressScroll="progressScroll" @progressScrollEnd="progressScrollEnd" @popupShow="popupShow($event,item,index)"></list-item-vue>
@progressScrollEnd="progressScrollEnd"
@popupShow="popupShow($event,item,index)"></list-item-vue>
</view> </view>
</cell> </cell>
</list> </list>
<view v-if="isH5||isIos" class=" w-full box" style="width: 100vw;"> <view v-if="isH5||isIos" class=" w-full box" style="width: 100vw;">
<swiper <swiper @longpress="popupShow('speed')" :style="{height:wHeight+'px'}" v-if="videoList.length"
@longpress="popupShow('speed')"
:style="{height:wHeight+'px'}" v-if="videoList.length"
@change="swiperChange" :current="current" :circular="true" vertical class="u-flex-1" @change="swiperChange" :current="current" :circular="true" vertical class="u-flex-1"
@transition="transition" :indicator-dots="false" :autoplay="false" :interval="0" :duration="200"> @transition="transition" :indicator-dots="false" :autoplay="false" :interval="0" :duration="200">
<swiper-item v-for="(item,index) in videoList" :key="index"> <swiper-item v-for="(item,index) in videoList" :key="index">
<list-item-vue :total="list.length" :item="item" :isCommand="isCommand" :height="wHeight" <list-item-vue :total="list.length" :item="item" :isCommand="isCommand" :height="wHeight"
:isAndriod="isAndriod" :isAndriod="isAndriod" :showAndriod="showAndriod" :isIos="isIos" :isH5="isH5" :isTabbar="isTabbar"
:showAndriod="showAndriod" @playStatusChange="playStatusChange" :showControls="control.showControls" :current="current"
:isIos="isIos" :isCollect="isCollect" @toDetail="toDetail(item,index)" @controlstoggles="controlstoggles"
:isH5="isH5" :playSpeeds="playSpeeds" :index="index" :nowIndex="nowIndex"
:isTabbar="isTabbar" @playStatusChange="playStatusChange" @dianzanClick="dianzanClick(item,index)" @share="share(item)" @zhuijuClick="zhuijuClick(item)"
:showControls="control.showControls" :current="current" :isCollect="isCollect" @popupShow="popupShow($event,item,index)"></list-item-vue>
@toDetail="toDetail(item,index)" @controlstoggles="controlstoggles" :playSpeeds="playSpeeds"
:index="index" :nowIndex="nowIndex" @dianzanClick="dianzanClick(item,index)" @share="share(item)"
@zhuijuClick="zhuijuClick(item)" @popupShow="popupShow($event,item,index)"></list-item-vue>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
@ -157,12 +147,12 @@
</view> </view>
<up-icon name="close" :size="16" color="#333" bold @click="popupClose('pay')"></up-icon> <up-icon name="close" :size="16" color="#333" bold @click="popupClose('pay')"></up-icon>
</view> </view>
<view class="u-m-t-30"> <view class="u-m-t-30">
<text class=" color-999 u-font-24">{{paytips}} </text> <text class=" color-999 u-font-24">{{paytips}} </text>
</view> </view>
<view class="u-m-t-30"> <view class="u-m-t-30">
<text class=" color-999 u-font-24">抽奖机会仅当日可用次日作废 </text> <text class=" color-999 u-font-24">抽奖机会仅当日可用次日作废 </text>
</view> </view>
<view class="colo-333 pay-list font-bold u-font-28 u-m-t-20"> <view class="colo-333 pay-list font-bold u-font-28 u-m-t-20">
<view class="pay-list-item" v-if="info&&info.price" @click="payBtnClick('money','all')"> <view class="pay-list-item" v-if="info&&info.price" @click="payBtnClick('money','all')">
<image class="hot" src="@/static/images/hot.png" mode=""></image> <image class="hot" src="@/static/images/hot.png" mode=""></image>
@ -183,7 +173,7 @@
</view> </view>
</view> </view>
</up-popup> </up-popup>
<!-- 支付确认 --> <!-- 支付确认 -->
<up-popup :show="popup.payTips" :round="10" @close="popupClose('payTips')" :customStyle="customStyle"> <up-popup :show="popup.payTips" :round="10" @close="popupClose('payTips')" :customStyle="customStyle">
@ -237,13 +227,53 @@
</view> </view>
</view> </view>
</up-popup> </up-popup>
<!-- 达到每天支付赠送抽奖次数上限时弹窗确认 -->
<up-popup :show="popup.payConfirm" mode="center" :round="22" @close="popupClose('payConfirm')"
:customStyle="payConfirmCustomStyle">
<view class="u-p-32">
<text class="u-font-32 color-333 font-bold u-text-center">付款确认</text>
<view class="u-p-l-14 u-p-r-14">
<view class="color-333 u-font-28 u-m-t-28 u-m-b-28 ">
<view class="u-flex u-flex-row">
<text class="u-font-28">今日已付款解锁{{payCount.canGetRedPackMax}}本次解锁后将</text>
<text class="no-get">不会获得</text>
</view>
<text class="u-font-28">抽奖机会请确认是否继续付款
</text>
</view>
<view class="u-flex u-flex-row u-row-between gap-20 u-p-l-28 u-p-r-28">
<text class="cancel-btn" @click="popupClose('payConfirm')">取消</text>
<text class="confirm-btn" @click="continuePay()">继续付款</text>
</view>
</view>
</view>
</up-popup>
<!-- 绑定微信 -->
<up-popup :show="popup.bindWx" mode="center" :round="22" @close="popupClose('bindWx')"
:customStyle="payConfirmCustomStyle">
<view class="u-p-32">
<text class="u-font-32 color-333 font-bold u-text-center">绑定微信</text>
<view class="u-p-l-14 u-p-r-14">
<text class="u-text-center color-333 u-font-28 u-m-t-28 u-m-b-28 ">
请先绑定微信再继续完成支付
</text>
<view class="u-flex u-flex-row u-row-between gap-20 u-p-l-28 u-p-r-28">
<text class="cancel-btn" @click="popupClose('bindWx')">取消</text>
<text class="confirm-btn" @click="bindWx()">立即绑定</text>
</view>
</view>
</view>
</up-popup>
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<my-poster ref="refPoster"></my-poster> <my-poster ref="refPoster"></my-poster>
<!-- #endif --> <!-- #endif -->
</template> </template>
<script setup> <script setup>
import {
toBindWx
} from '@/utils/wx.js'
import { import {
useCommonStore useCommonStore
} from '@/store/common.js' } from '@/store/common.js'
@ -276,16 +306,26 @@
onUnmounted onUnmounted
} from 'vue'; } from 'vue';
//
let scrollable=ref(true) function bindWx(){
popupClose('bindWx')
function progressScroll(){ toBindWx()
scrollable.value=false
} }
function progressScrollEnd(){
scrollable.value=true const payConfirmCustomStyle = {
width: '694rpx'
} }
let scrollable = ref(true)
function progressScroll() {
scrollable.value = false
}
function progressScrollEnd() {
scrollable.value = true
}
let isH5 = false let isH5 = false
// #ifdef H5 // #ifdef H5
@ -297,9 +337,9 @@
const showAndriod = !isH5 && isAndriod ? true : false const showAndriod = !isH5 && isAndriod ? true : false
let initing = true let initing = true
const refPoster = ref(null) const refPoster = ref(null)
let paytips=ref('') let paytips = ref('')
const props = defineProps({ const props = defineProps({
list: { list: {
type: Array, type: Array,
@ -336,8 +376,8 @@
} }
} }
}) })
const control = reactive({ const control = reactive({
showBack: true, showBack: true,
showControls: true showControls: true
@ -417,9 +457,11 @@
const popup = reactive({ const popup = reactive({
show: false, show: false,
pay: false, pay: false,
bindWx: false,
payTips: false, payTips: false,
speed: false, speed: false,
data: null, data: null,
payConfirm: false,
payType: null payType: null
}) })
@ -556,45 +598,67 @@
if (num == 1) { if (num == 1) {
data.courseDetailsId = popup.data.courseDetailsId data.courseDetailsId = popup.data.courseDetailsId
} }
try {
const res = num == '10' ? await Api.buyTenVideo(data) : await Api.buyVideo(data) const res = num == '10' ? await Api.buyTenVideo(data) : await Api.buyVideo(data)
console.log(res); if (res && res.code == 407) {
if (!res.orders) { popupShow('bindWx')
return uni.showToast({ return
title: '创建订单失败', }
icon: 'none' if (!res || !res.orders) {
}) return uni.showToast({
} title: '创建订单失败',
if (res) { icon: 'none'
if (type == 'gold') {
goldPay({
orderId: res.orders.ordersId
})
} else {
payOrder({
orderId: res.orders.ordersId
}) })
} }
if (res) {
if (type == 'gold') {
goldPay({
orderId: res.orders.ordersId
})
} else {
payOrder({
orderId: res.orders.ordersId
})
}
} else { } else {
}
} catch (error) {
console.log(error);
} }
} }
function payBtnClick(type, num) {
async function payBtnClick(type, num) {
console.log(type, num); console.log(type, num);
popup.payType = `${type}-${num}` popup.payType = `${type}-${num}`
if (type == 'gold') { if (type == 'gold') {
return payConfirm() return payConfirm()
} }
try {
if (payCount.now > payCount.canGetRedPackMax) {
popupShow('payConfirm')
return
}
popupClose('show')
popupShow('payTips')
} catch (error) {}
}
function continuePay() {
popupClose('payConfirm')
popupClose('show') popupClose('show')
popupShow('payTips') popupShow('payTips')
} }
function jiClick(item, index) { function jiClick(item, index) {
initing = false initing = false
let newCurrent = (current.value + 1) % 3; let newCurrent = (current.value + 1) % 3;
@ -659,6 +723,18 @@
} }
} }
const payCount = reactive({
canGetRedPackMax: 0,
now: 1,
})
function extractNumbers(str) {
const numbers = str.match(/\d+/g);
if (numbers) {
return numbers.map(num => parseInt(num, 10));
}
return [];
}
async function popupShow(key = 'show', item, index) { async function popupShow(key = 'show', item, index) {
console.log(key, item, 'debug'); console.log(key, item, 'debug');
console.log('key' + popup[key]); console.log('key' + popup[key]);
@ -673,10 +749,16 @@
xuanjiInit() xuanjiInit()
// #endif // #endif
} }
if(key=='pay'){ if (key == 'pay') {
const res=await Api.getPayTips() const res = await Api.getPayTips()
console.log(res); const numbers = extractNumbers(res)
paytips.value=res console.log(numbers);
if (numbers.length >= 2) {
payCount.canGetRedPackMax = numbers[0]
payCount.now = numbers[1]
console.log(payCount);
}
paytips.value = res
} }
popup[key] = true popup[key] = true
if (item) { if (item) {
@ -802,9 +884,11 @@
} }
function share(item) { function share(item) {
const {qdCode}= uni.getStorageSync('userInfo')||{} const {
qdCode
} = uni.getStorageSync('userInfo') || {}
const urls = returnShareUrl() + '/me/detail/detail?id=' + item.courseId + '&courseDetailsId=' + item const urls = returnShareUrl() + '/me/detail/detail?id=' + item.courseId + '&courseDetailsId=' + item
.courseDetailsId + '&invitation=' + uni.getStorageSync('invitationCode') + '&qdCode=' +qdCode; .courseDetailsId + '&invitation=' + uni.getStorageSync('invitationCode') + '&qdCode=' + qdCode;
console.log(urls); console.log(urls);
// #ifdef H5 // #ifdef H5
refPoster.value.make({ refPoster.value.make({
@ -850,7 +934,8 @@
setVideoList(item) setVideoList(item)
} }
const refPopup=ref(null) const refPopup = ref(null)
function setVideoList(item) { function setVideoList(item) {
@ -1114,8 +1199,8 @@
} }
} }
} }
.ji-item:nth-of-type(3n) { .ji-item:nth-of-type(3n) {
margin-right: 0; margin-right: 0;
} }
@ -1222,4 +1307,22 @@
border-radius: 10px 10px 0 0; border-radius: 10px 10px 0 0;
background-color: #fff; background-color: #fff;
} }
.cancel-btn,
.confirm-btn {
width: 210rpx;
height: 70rpx;
line-height: 70rpx;
text-align: center;
font-size: 32rpx;
color: #fff;
background: #ED838A;
box-shadow: inset 0rpx -6rpx 12rpx 0rpx rgba(255, 255, 255, 0.77);
border-radius: 40rpx 40rpx 40rpx 40rpx;
}
.no-get {
color: #FF5560;
font-size: 32rpx;
}
</style> </style>

View File

@ -7,6 +7,7 @@ import {
reject reject
} from "lodash"; } from "lodash";
import config from "@/commons/config.js"; import config from "@/commons/config.js";
// 测试服 // 测试服
let baseUrl = config.baseApiUrl + "app"; let baseUrl = config.baseApiUrl + "app";
const loadingShowTime = 200; const loadingShowTime = 200;
@ -86,11 +87,29 @@ function commonsProcess(showLoading, httpReqCallback, isreturm) {
isShowErrorToast = true; isShowErrorToast = true;
return Promise.reject(bodyData); // 跳转到catch函数 return Promise.reject(bodyData); // 跳转到catch函数
} }
let result = null;
if (bodyData.hasOwnProperty('data')) {
result = bodyData.data
} else if (bodyData.hasOwnProperty('page')) {
result = bodyData.page
} else {
result = bodyData
}
//未绑定微信
if (bodyData.code == 407) {
return Promise.resolve(result);
}
if (bodyData.code != 0) { if (bodyData.code != 0) {
infoBox.showToast(data.message); infoBox.showToast(data.message);
return; return;
} }
// 加密数据 // 加密数据
if (!bodyData.data && bodyData.encryptData) { if (!bodyData.data && bodyData.encryptData) {
return Promise.resolve({ return Promise.resolve({
@ -98,16 +117,8 @@ function commonsProcess(showLoading, httpReqCallback, isreturm) {
code: bodyData.code, code: bodyData.code,
}); });
} }
let result=null;
if(bodyData.hasOwnProperty('data')){
result=bodyData.data
}
else if(bodyData.hasOwnProperty('page')){
result=bodyData.page
}
else{
result=bodyData
}
// 构造请求成功的响应数据 // 构造请求成功的响应数据
return Promise.resolve(result); return Promise.resolve(result);
}) })
@ -125,7 +136,7 @@ function commonsProcess(showLoading, httpReqCallback, isreturm) {
}); });
reject(); reject();
} }
if (res.code != 0&&res.code != 401) { if (res.code != 0 && res.code != 401) {
infoBox.showToast(res.msg).then(() => {}); infoBox.showToast(res.msg).then(() => {});
reject(); reject();
} }

View File

@ -30,7 +30,8 @@
"Camera" : {}, "Camera" : {},
"Push" : {}, "Push" : {},
"VideoPlayer" : {}, "VideoPlayer" : {},
"Canvas" : "nvue canvas" //使Canvas "Canvas" : "nvue canvas", //使Canvas
"OAuth" : {}
}, },
/* */ /* */
"distribute" : { "distribute" : {
@ -74,6 +75,12 @@
}, },
"ad" : { "ad" : {
"ks" : {} "ks" : {}
},
"oauth" : {
"weixin" : {
"appid" : "wx5001ff1af6c4781f",
"UniversalLinks" : ""
}
} }
}, },
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ], "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],

View File

@ -210,6 +210,13 @@
{ {
"navigationBarTitleText" : "兑换" "navigationBarTitleText" : "兑换"
} }
},
{
"path" : "pages/login/bindWx",
"style" :
{
"navigationBarTitleText" : "绑定微信"
}
} }
], ],
"globalStyle": { "globalStyle": {

86
pages/login/bindWx.vue Normal file
View File

@ -0,0 +1,86 @@
<template>
<view class="u-p-30 min-page u-flex u-flex-col u-row-center u-col-center">
<view class="u-relative w-full">
<view class="u-absolute u-flex u-row-center wx-box" >
<image src="@/static/images/wx.png" class="img" mode=""></image>
</view>
<up-button type="" class="" :custom-style="customStyl" @click="bindwx">绑定微信</up-button>
<up-button type="" @click="navback">取消</up-button>
</view>
</view>
</template>
<script setup>
import {
onShow,onHide,onUnload,onLoad
} from '@dcloudio/uni-app'
import {
$bindWx
} from '@/api/login/login.js'
import {
bindWx
} from '@/utils/wx.js'
import color from '@/commons/color.js'
import {
reactive
} from 'vue';
const customStyl = reactive({
backgroundColor: color.main,
color: '#fff'
})
function navback() {
uni.navigateBack()
}
function clear(){
clearTimeout(timer)
}
let timer=null
async function bindwx() {
const code =await bindWx()
const res = await $bindWx({
code
})
console.log(res);
if (res) {
uni.showToast({
title: '绑定微信成功',
icon: 'none'
})
clear()
timer=setTimeout(()=>{
uni.navigateBack()
},1500)
}else{
uni.showToast({
title: '绑定微失败',
icon: 'none'
})
}
}
onUnload(() => {
clear()
})
</script>
<style lang="scss" scoped>
.wx-box{
position: absolute;
left: 0;
right: 0;
bottom: 100%;
display: flex;
justify-content: center;
transform: translateY(-100rpx);
.img{
width: 200rpx;
height: 200rpx;
}
}
</style>

View File

@ -9,13 +9,17 @@
<image class="img" src="/static/logo.png" mode="widthFix"></image> <image class="img" src="/static/logo.png" mode="widthFix"></image>
</view> </view>
<view class="quick-menu"> <view class="quick-menu">
<image class="icon" src="/static/me/logo_btn1.png" mode="aspectFit" @click="linkTo('/pages/share/index', true)"></image> <image class="icon" src="/static/me/logo_btn1.png" mode="aspectFit"
<image class="icon" src="/static/me/logo_btn2.png" mode="aspectFit" @click="linkTo('/pages/me/message', true)"></image> @click="linkTo('/pages/share/index', true)"></image>
<image class="icon" src="/static/me/logo_btn3.png" mode="aspectFit" @click="linkTo('/pages/me/contact', true)"></image> <image class="icon" src="/static/me/logo_btn2.png" mode="aspectFit"
@click="linkTo('/pages/me/message', true)"></image>
<image class="icon" src="/static/me/logo_btn3.png" mode="aspectFit"
@click="linkTo('/pages/me/contact', true)"></image>
</view> </view>
</view> </view>
<view class="top" @click="linkTo(userInfo.phone?'/pages/me/userInfo':'/pages/login/login')"> <view class="top" @click="linkTo(userInfo.phone?'/pages/me/userInfo':'/pages/login/login')">
<image class="avatar" :src="userInfo.avatar || '/static/default_avatar.png'" mode="aspectFill"></image> <image class="avatar" :src="userInfo.avatar || '/static/default_avatar.png'" mode="aspectFill">
</image>
<view class="info-wrap"> <view class="info-wrap">
<view class="name">{{ userInfo.phone || '请登录' }}</view> <view class="name">{{ userInfo.phone || '请登录' }}</view>
</view> </view>
@ -44,7 +48,7 @@
<div @click="linkTo('/pages/me/gold_record', true)"> <div @click="linkTo('/pages/me/gold_record', true)">
<view class="btn">金币明细</view> <view class="btn">金币明细</view>
</div> </div>
</view> </view>
<div class="title-wrap" @click="linkTo('/pages/watching_history/watching_history?type=3', true)"> <div class="title-wrap" @click="linkTo('/pages/watching_history/watching_history?type=3', true)">
<view class="a"> <view class="a">
@ -52,14 +56,10 @@
<up-icon name="arrow-right"></up-icon> <up-icon name="arrow-right"></up-icon>
</view> </view>
</div> </div>
<view class="history-list"> <view class="history-list">
<view <view class="item" v-for="item in recordThree" :key="item.id"
class="item" @click="linkTo(`/pages/video/detail?courseId=${item.courseId}&courseDetailsId=${item.courseDetailsId}`)">
v-for="item in recordThree"
:key="item.id"
@click="linkTo(`/pages/video/detail?courseId=${item.courseId}&courseDetailsId=${item.courseDetailsId}`)"
>
<image class="cover" :src="item.titleImg" mode="aspectFill"></image> <image class="cover" :src="item.titleImg" mode="aspectFill"></image>
<view class="name">{{ item.title }}</view> <view class="name">{{ item.title }}</view>
<view class="t">看到{{ item.courseDetailsName }}</view> <view class="t">看到{{ item.courseDetailsName }}</view>
@ -99,6 +99,13 @@
<image class="icon" src="/static/me/menu_icon7.png" mode="aspectFit"></image> <image class="icon" src="/static/me/menu_icon7.png" mode="aspectFit"></image>
<view class="name">关于我们</view> <view class="name">关于我们</view>
</view> --> </view> -->
<!-- #ifndef H5 -->
<view class="item" @click="bindwx" v-if="!isBindWx">
<image class="icon" src="/static/me/bind_wx.png" mode="aspectFit"></image>
<view class="name">绑定微信</view>
</view>
<!-- #endif -->
<view class="item" @click="linkTo('/pages/me/privacy')"> <view class="item" @click="linkTo('/pages/me/privacy')">
<image class="icon" src="/static/me/menu_icon8.png" mode="aspectFit"></image> <image class="icon" src="/static/me/menu_icon8.png" mode="aspectFit"></image>
<view class="name">隐私政策</view> <view class="name">隐私政策</view>
@ -110,286 +117,359 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive } from 'vue'; import {
import { onLoad,onShow, onPullDownRefresh } from '@dcloudio/uni-app'; ref,
import { selectByUserId, collectVideoSummary, selectUserMoney } from '@/api/me/me.js'; reactive
import { linkTo } from '@/utils/app.js'; } from 'vue';
import { import {
onLoad,
onShow,
onPullDownRefresh
} from '@dcloudio/uni-app';
import {
selectByUserId,
collectVideoSummary,
selectUserMoney
} from '@/api/me/me.js';
import {
linkTo
} from '@/utils/app.js';
import {
useCommonStore useCommonStore
} from '@/store/common.js' } from '@/store/common.js'
import {toBindWx,bindStatus} from '@/utils/wx.js'
const $common = useCommonStore() const $common = useCommonStore()
const userInfo = ref({}); const userInfo = ref({});
//
const recordThree = ref([]);
onShow(()=>{
// ios
$common.init()
})
async function selectByUserIdAjax() {
try {
const res = await selectByUserId({ page: 1, limit: 3, classify: 3 });
recordThree.value = res.records;
} catch (error) {
console.log(error);
}
}
//
const likeData = reactive({
likeCount: 0,
collectCount: 0
});
async function collectVideoSummaryAjax() {
try {
const res = await collectVideoSummary();
likeData.likeCount = res.likeCount;
likeData.collectCount = res.collectCount;
} catch (error) {
console.log(error);
}
}
//
const gold = ref(0);
const amount = ref(0);
async function selectUserMoneyAjax() {
try {
const res = await selectUserMoney();
gold.value = res.money;
amount.value = res.amount;
} catch (error) {
console.log(error);
}
}
//
function toTask() {
linkTo('/pages/share/index');
}
onPullDownRefresh(async () => {
await selectByUserIdAjax();
await collectVideoSummaryAjax();
await selectUserMoneyAjax();
userInfo.value = uni.getStorageSync('userInfo');
setTimeout(() => {
uni.stopPullDownRefresh();
}, 500);
});
onShow(() => {
if(uni.getStorageSync('token')){
selectByUserIdAjax();
collectVideoSummaryAjax();
selectUserMoneyAjax();
userInfo.value = uni.getStorageSync('userInfo');
}
}); let isBindWx=ref(false)
async function bindwx(){
if(isBindWx.value){
uni.showToast({
title: '已绑定微信,请勿重复绑定',
icon: 'none'
})
return
}
isBindWx.value=await bindStatus()
console.log(isBindWx.value);
if(isBindWx.value){
uni.showToast({
title: '已绑定微信,请勿重复绑定',
icon: 'none'
})
return
}else{
toBindWx()
}
}
//
const recordThree = ref([]);
onShow(() => {
// ios
$common.init()
})
async function selectByUserIdAjax() {
try {
const res = await selectByUserId({
page: 1,
limit: 3,
classify: 3
});
recordThree.value = res.records;
} catch (error) {
console.log(error);
}
}
//
const likeData = reactive({
likeCount: 0,
collectCount: 0
});
async function collectVideoSummaryAjax() {
try {
const res = await collectVideoSummary();
likeData.likeCount = res.likeCount;
likeData.collectCount = res.collectCount;
} catch (error) {
console.log(error);
}
}
//
const gold = ref(0);
const amount = ref(0);
async function selectUserMoneyAjax() {
try {
const res = await selectUserMoney();
gold.value = res.money;
amount.value = res.amount;
} catch (error) {
console.log(error);
}
}
//
function toTask() {
linkTo('/pages/share/index');
}
onPullDownRefresh(async () => {
await selectByUserIdAjax();
await collectVideoSummaryAjax();
await selectUserMoneyAjax();
userInfo.value = uni.getStorageSync('userInfo');
setTimeout(() => {
uni.stopPullDownRefresh();
}, 500);
});
onShow(() => {
if (uni.getStorageSync('token')) {
selectByUserIdAjax();
collectVideoSummaryAjax();
selectUserMoneyAjax();
userInfo.value = uni.getStorageSync('userInfo');
}
});
</script> </script>
<style> <style>
page { page {
background: #f5f7ff; background: #f5f7ff;
} }
</style> </style>
<style scoped lang="scss"> <style scoped lang="scss">
$bgColor: #f5f7ff; $bgColor: #f5f7ff;
.container { .container {
font-size: 28upx; font-size: 28upx;
color: #333; color: #333;
}
.top-bg {
width: 100%;
height: 50%;
position: fixed;
top: 0;
left: 0;
background: linear-gradient(90deg, #ffe5ea 0, #e4f5fb 49%, #fff0ee);
&::after {
content: '';
height: 50%;
width: 100%;
background: linear-gradient(to bottom, transparent, $bgColor);
position: absolute;
bottom: 0;
left: 0;
} }
}
.content { .top-bg {
padding: 28upx; width: 100%;
position: relative; height: 50%;
.user-info { position: fixed;
.logo-wrap { top: 0;
display: flex; left: 0;
align-items: center; background: linear-gradient(90deg, #ffe5ea 0, #e4f5fb 49%, #fff0ee);
justify-content: space-between;
.logo { &::after {
width: 160upx; content: '';
.img { height: 50%;
width: 100%; width: 100%;
display: block; background: linear-gradient(to bottom, transparent, $bgColor);
position: absolute;
bottom: 0;
left: 0;
}
}
.content {
padding: 28upx;
position: relative;
.user-info {
.logo-wrap {
display: flex;
align-items: center;
justify-content: space-between;
.logo {
width: 160upx;
.img {
width: 100%;
display: block;
}
}
.quick-menu {
display: flex;
gap: 20upx;
.icon {
$size: 60upx;
width: $size;
height: $size;
}
} }
} }
.quick-menu {
.top {
display: flex; display: flex;
gap: 20upx; align-items: center;
padding-top: 40upx;
.avatar {
$size: 94upx;
width: $size;
height: $size;
border-radius: 50%;
margin-right: 12upx;
}
.info-wrap {
flex: 1;
display: flex;
flex-direction: column;
font-size: 32upx;
}
}
.btm {
display: flex;
padding: 40upx 0;
.item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.title {
font-size: 28upx;
}
.num {
font-weight: bold;
display: flex;
justify-content: center;
}
}
}
}
}
.card-wrap {
background: #fff;
border-radius: 16upx;
overflow: hidden;
margin-bottom: 28upx;
.gold-wrap {
background: #f2b5b5;
display: flex;
justify-content: space-between;
padding: 20upx 28upx;
position: relative;
// &::after {
// $size: 40upx;
// content: '';
// width: $size;
// height: $size;
// border-radius: 8upx;
// transform: rotate(45deg);
// position: absolute;
// left: 50%;
// margin-left: $size * 0.5 * -1;
// bottom: $size * 0.3 * -1;
// background: inherit;
// }
.left {
display: flex;
align-items: center;
.icon { .icon {
$size: 60upx; $size: 52upx;
width: $size;
height: $size;
margin-right: 20upx;
}
.num {
color: #fff;
font-size: 32upx;
}
}
.btn {
color: #977641;
background: linear-gradient(90deg, #fee7bc 0%, #fdcc89 100%);
width: 144upx;
height: 56upx;
border-radius: 56upx;
display: flex;
align-items: center;
justify-content: center;
font-size: 24upx;
}
}
.title-wrap {
padding: 28upx;
.a {
display: flex;
align-items: center;
justify-content: space-between;
.t {
font-size: 28upx;
}
}
}
.history-list {
padding: 0 28upx 28upx;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 1fr;
grid-column-gap: 28upx;
grid-row-gap: 28upx;
.item {
.cover {
width: 100%;
height: 280upx;
border-radius: 20upx;
}
.name {
font-size: 28upx;
width: 160upx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.t {
color: #999;
font-size: 24upx;
}
}
}
.menu-list {
display: flex;
flex-wrap: wrap;
padding: 28upx 0 0;
.item {
flex: 0 0 25%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-bottom: 32upx;
.icon {
$size: 56upx;
width: $size; width: $size;
height: $size; height: $size;
} }
}
} .name {
.top { font-size: 24upx;
display: flex; margin-top: 8upx;
align-items: center; color: #333;
padding-top: 40upx;
.avatar {
$size: 94upx;
width: $size;
height: $size;
border-radius: 50%;
margin-right: 12upx;
}
.info-wrap {
flex: 1;
display: flex;
flex-direction: column;
font-size: 32upx;
}
}
.btm {
display: flex;
padding: 40upx 0;
.item {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.title {
font-size: 28upx;
}
.num {
font-weight: bold;
display: flex;
justify-content: center;
} }
} }
} }
} }
} </style>
.card-wrap {
background: #fff;
border-radius: 16upx;
overflow: hidden;
margin-bottom: 28upx;
.gold-wrap {
background: #f2b5b5;
display: flex;
justify-content: space-between;
padding: 20upx 28upx;
position: relative;
// &::after {
// $size: 40upx;
// content: '';
// width: $size;
// height: $size;
// border-radius: 8upx;
// transform: rotate(45deg);
// position: absolute;
// left: 50%;
// margin-left: $size * 0.5 * -1;
// bottom: $size * 0.3 * -1;
// background: inherit;
// }
.left {
display: flex;
align-items: center;
.icon {
$size: 52upx;
width: $size;
height: $size;
margin-right: 20upx;
}
.num {
color: #fff;
font-size: 32upx;
}
}
.btn {
color: #977641;
background: linear-gradient(90deg, #fee7bc 0%, #fdcc89 100%);
width: 144upx;
height: 56upx;
border-radius: 56upx;
display: flex;
align-items: center;
justify-content: center;
font-size: 24upx;
}
}
.title-wrap {
padding: 28upx;
.a {
display: flex;
align-items: center;
justify-content: space-between;
.t {
font-size: 28upx;
}
}
}
.history-list {
padding: 0 28upx 28upx;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 1fr;
grid-column-gap: 28upx;
grid-row-gap: 28upx;
.item {
.cover {
width: 100%;
height: 280upx;
border-radius: 20upx;
}
.name {
font-size: 28upx;
width: 160upx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.t {
color: #999;
font-size: 24upx;
}
}
}
.menu-list {
display: flex;
flex-wrap: wrap;
padding: 28upx 0 0;
.item {
flex: 0 0 25%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-bottom: 32upx;
.icon {
$size: 56upx;
width: $size;
height: $size;
}
.name {
font-size: 24upx;
margin-top: 8upx;
color: #333;
}
}
}
}
</style>

BIN
static/images/wx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
static/me/bind_wx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

45
utils/wx.js Normal file
View File

@ -0,0 +1,45 @@
import {
$bindWx,
$bindStatus
} from '@/api/login/login.js'
// 绑定状态
export async function bindStatus() {
const res = await $bindStatus()
return res.wxBind ? true : false;
}
export function toBindWx() {
uni.navigateTo({
url: '/pages/login/bindWx'
})
}
//绑定微信
export async function bindWx() {
console.log('bindWx');
const isBind = await bindStatus()
if (isBind) {
uni.showToast({
title: '已绑定微信,请勿重复绑定',
icon: 'none'
})
return
}
return new Promise((reslove, reject) => {
uni.login({
"provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证
success: function(loginRes) {
console.log(loginRes);
reslove(loginRes.code)
},
fail: function(err) {
// 登录授权失败
// err.code是错误码
console.log(err);
reject()
}
});
})
}