Browse Source

Improve change phone validation and prefer BigPicLink for video posters

master
kola-web 2 days ago
parent
commit
6d81de316a
  1. 101
      src/pages/changePhone/index.ts
  2. 2
      src/pages/repository/index.wxml

101
src/pages/changePhone/index.ts

@ -1,78 +1,87 @@
const app = getApp<IAppOption>(); const app = getApp<IAppOption>()
let timer = null as null | number; let timer = null as null | number
Page({ Page({
data: { data: {
mobile: "", mobile: '',
code: "", code: '',
codeText: "发送验证码", codeText: '发送验证码',
}, },
onLoad() {}, onLoad() {},
getCode() { getCode() {
if (timer) return; if (timer) return
const mobile = this.data.mobile; const mobile = this.data.mobile
if (!mobile) { if (!mobile) {
wx.showToast({ wx.showToast({
title: "手机号不能为空", title: '手机号不能为空',
icon: "none", icon: 'none',
}); })
return; return
} }
// 验证手机号 // 验证手机号
if (!/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(mobile)) { if (!/^1[3-9]\d{9}$/.test(mobile)) {
wx.showToast({ wx.showToast({
title: "手机号格式不正确", title: '手机号格式不正确',
icon: "none", icon: 'none',
}); })
return; return
} }
wx.ajax({ wx.ajax({
method: "POST", method: 'POST',
url: "?r=igg4/login/send-verify-code", url: '?r=igg4/login/send-verify-code',
data: { data: {
mobile, mobile,
}, },
}).then((res) => { }).then((_res) => {
console.log(res);
wx.showToast({ wx.showToast({
icon: "none", icon: 'none',
title: "验证码已发送~", title: '验证码已发送~',
}); })
let time = 60; let time = 60
timer = setInterval(() => { timer = setInterval(() => {
time--; time--
this.setData({ this.setData({
codeText: time + "s后重新发送", codeText: `${time}s后重新发送`,
}); })
if (time <= 0) { if (time <= 0) {
clearInterval(timer as number); clearInterval(timer as number)
timer = null; timer = null
this.setData({ this.setData({
codeText: "发送验证码", codeText: '发送验证码',
}); })
} }
}, 1000); }, 1000)
}); })
}, },
handleSubmit() { handleSubmit() {
const { mobile, code } = this.data; if (!this.data.mobile) {
const { registrationSource, registChannel, regBusinessId } = app.globalData; wx.showToast({
icon: 'none',
title: '请输入手机号',
})
return
}
if (!this.data.code) {
wx.showToast({
icon: 'none',
title: '请输入验证码',
})
return
}
wx.ajax({ wx.ajax({
method: "POST", method: 'POST',
url: "?r=igg4/account/update-telephone", url: '?r=igg4/account/update-telephone',
data: { data: {
mobile, mobile: this.data.mobile,
code, code: this.data.code,
registrationSource,
registChannel,
regBusinessId,
}, },
}).then((_res) => { }).then((_res) => {
wx.navigateBack(); app.getUserInfo(this, true)
}); wx.navigateBack()
})
}, },
handleBack() { handleBack() {
wx.navigateBack(); wx.navigateBack()
}, },
}); })

2
src/pages/repository/index.wxml

@ -95,7 +95,7 @@
<view class="video-list" wx:if="{{active==1 && list.length}}"> <view class="video-list" wx:if="{{active==1 && list.length}}">
<view class="list-item" wx:for="{{list}}" bind:tap="handleDetail" data-id="{{item.Id}}" data-index="{{index}}" wx:key="index"> <view class="list-item" wx:for="{{list}}" bind:tap="handleDetail" data-id="{{item.Id}}" data-index="{{index}}" wx:key="index">
<view class="photo"> <view class="photo">
<image class="poster" mode="widthFix" src="{{item.TitlePicLink}}"></image> <image class="poster" mode="widthFix" src="{{item.BigPicLink || item.TitlePicLink}}"></image>
</view> </view>
<view class="inner"> <view class="inner">
<view class="title">{{item.Title}}</view> <view class="title">{{item.Title}}</view>

Loading…
Cancel
Save