1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <template>
- <view>
- <u-notify ref="uNotify"></u-notify>
- <view class="logoBox text-center">
- <view class="logo">
- <!-- <u--image :showLoading="true" shape="circle" :src="getFilePath(logo)" width="100px" height="100px"></u--image> -->
- </view>
- <view class="">欢迎加入{{appName}}</view>
- </view>
- <view class="invalidColor fz14px text-center mb20px">申请获取您的微信绑定手机号</view>
- <view class="contain">
- <u-button text="一键注册" type="success" openType="getPhoneNumber" @getphonenumber="decryptPhoneNumber"></u-button>
- </view>
- </view>
- </template>
- <script>
- // import {
- // logo
- // } from '../../env/dev';
- export default {
- data() {
- return {
- // logo: this.logo,
- // appName: this.appName
- appName: '餐车活动'
- };
- },
- onLoad(options) { // 监听页面加载
- },
- onUnload() { // 监听页面卸载
- },
- onShow() { // 监听页面显示
- },
- onHide() { // 监听页面隐藏
- },
- onReachBottom() { // 上拉触底
- },
- methods: {
- async decryptPhoneNumber(e) {
- // 获取手机号
- let result = await this.$request('post', '/userinfo/auth/getWxPhone', {
- code: e.detail.code,
- appid: this.appId
- })
- if (!result) {
- uni.showToast({
- title: '授权失败',
- icon: 'success'
- })
- return
- }
- const code = await new Promise((resolve) => {
- uni.login({
- success: (res) => {
- resolve(res.code)
- },
- fail: () => {
- resolve(false)
- }
- })
- })
- // 注册
- const res = await this.$request('post', '/userinfo/auth/bindPhone', {
- code,
- appid: this.appId,
- phone: result.msg
- })
- if (res) {
- uni.showToast({
- title: '注册成功',
- icon: 'success'
- })
- uni.setStorageSync("token", res.data.token);
- await this.getUser()
- uni.navigateBack(-1)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .logoBox {
- margin: 200rpx 0 300rpx;
- .logo {
- display: inline-block;
- }
- }
- </style>
|