123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- <template>
- <view class="page">
- <view class="header">
- <view class="left">
- <!-- <image class="img" mode="widthFix" src="../../static/login/close.png"></image> -->
- </view>
- </view>
- <view class="tbody">
- <block v-if="type == 'onelogin'">
- <image class="icon" mode="widthFix" src="../../static/me/avator.png"></image>
- <text class="mobile">+ 86 1**********</text>
- <text class="tips">首次验证通过即注册遇见玛特账号</text>
- <text class="btn_submit">本机号码一键登录</text>
- <view class="other">
- <view class="pass" @click="type = 'pass'">密码登录</view>
- <view class="line"></view>
- <view class="mob" @click="type = 'mobile'">手机号登录</view>
- </view>
- </block>
- <block v-if="type == 'pass' || type == 'mobile'">
- <view class="name">手机号码:</view>
- <view class="item">
- <input type="text" class="input" v-model="mobile" placeholder="请输入手机号码" maxlength="11" />
- </view>
- <block v-if="type == 'pass'">
- <view class="name">登录密码:</view>
- <view class="item">
- <input type="password" class="input" v-model="password" placeholder="请输入登录密码" maxlength="32" />
- </view>
- <view class="other_list">
- <text class="left" v-if="true" @click="type = 'mobile'">验证码登录</text>
- <text class="left" v-else></text>
- <text class="right" @click="type = 'mobile'" v-if="false">验证码登录</text>
- <text class="right" @click="toRegist">还没有账号?开始注册</text>
- </view>
- </block>
- <block v-if="type == 'mobile'">
- <view class="name">验证码:</view>
- <view class="item">
- <input type="text" class="input" v-model="code" placeholder="请输入验证码" maxlength="6" />
- <view class="btn" v-if="captchaTime === 0" @click="getCode">获取验证码</view>
- <view class="btn" v-if="captchaTime > 0">{{captchaTime}}秒后重试</view>
- </view>
- <view class="other_list">
- <text class="left"></text>
- <text class="right" @click="type = 'pass'">密码登录</text>
- </view>
- </block>
- <text class="btn_submit" @click="toLogin">登录</text>
- </block>
- <view class="wechat" v-if="false">
- <image class="img" mode="widthFix" src="../../static/login/wechat.png"></image>
- </view>
- <view class="agree">
- <view class="agree2" @click="agreeChk()">
- <image mode="widthFix" src="../../static/login/sel_no.png" v-if="is_agree == 0"></image>
- <image mode="widthFix" src="../../static/login/sel_yes.png" v-if="is_agree == 1"></image>
- <text>我已阅读并同意</text>
- </view>
- 《
- <text class="xy" @click="goPage('yhxy')">
- 隐私协议
- </text>
- 》和《
- <text class="xy" @click="goPage('yszc')">
- 用户使用协议
- </text>
- 》
- </view>
- <view class="agree" v-if="false"><text class="agree2">{{push_token}}</text></view>
- </view>
- <view class="blankHeight"></view>
- <DialogBox ref="DialogBox"></DialogBox>
- </view>
- </template>
- <script>
- import pubc from '@/common/public.js'
- export default {
- components: {},
- data() {
- return {
- skey: '',
- sel: 1,
- is_agree: 0,
- type: 'pass',
- myinfo: {
- nickname: '王思思',
- join_name: '注册日期:2024年5月',
- num_1: 0,
- num_2: 0,
- num_3: 0,
- num_4: 0,
- is_login: 'no',
- num_history: 0,
- num_collection: 0
- },
- mobile: '',
- password: '',
- code: '',
- captchaTime: 0,
- push_token: '',
- lat: '',
- lng: '',
- }
- },
- onLoad() {
- setTimeout(function() {
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: '#00000000',
- animation: {
- duration: 400,
- timingFunc: 'easeIn'
- }
- })
- }, 200);
- let that = this;
- uni.getPushClientId({
- success: (res) => {
- console.log("su:", res.cid);
- that.push_token = res.cid;
- },
- fail(err) {
- that.push_token = '';
- console.log(err)
- }
- });
- },
- onShow() {
- // let hsign = pubc.Encrypt("aboa-wifl-kwfl-zjfk-wlaa_FA0412932BAE9D98506580ADB348BEF9");
- // console.log("hsign", hsign)
- let skey = uni.getStorageSync("wapptoken");
- if (skey != null && skey != "" && skey != undefined) {
- uni.switchTab({
- url: "/pages/index/index"
- });
- return;
- }
- // let that = this;
- // uni.getLocation({
- // type: 'wgs84',
- // success: function(res) {
- // that.lat = res.latitude;
- // that.lng = res.longitude;
- // },
- // fail: function(error) {
- // console.error('获取位置失败:', error);
- // }
- // });
- },
- methods: {
- onBack() {},
- agreeChk() {
- if (this.is_agree == 0) {
- this.is_agree = 1;
- } else {
- this.is_agree = 0;
- }
- },
- goPage(page) {
- if (page == 'yhxy') {
- uni.navigateTo({
- url: '/pages/AboutUs/yhxy'
- })
- } else if (page == 'yszc') {
- uni.navigateTo({
- url: '/pages/AboutUs/yszc'
- })
- } else {
- uni.navigateTo({
- url: page,
- });
- }
- },
- toRegist() {
- uni.navigateTo({
- url: "/pages/login/reg",
- });
- },
- toLogin() {
- console.log('aaa');
- let that = this;
- if (this.mobile.length != 11) {
- uni.showToast({
- title: "请输入手机号",
- icon: "none",
- });
- return;
- }
- if (this.type == 'pass') {
- if (this.password.length < 6) {
- uni.showToast({
- title: "请输入不小于6位的密码",
- icon: "none",
- });
- return;
- }
- } else {
- if (this.code.length < 4) {
- uni.showToast({
- title: "请输入手机验证码",
- icon: "none",
- });
- return;
- }
- }
- if (this.is_agree == 0) {
- uni.showToast({
- title: "请确认并选择协议",
- icon: "none",
- });
- return;
- }
- let method = '/Member/gamelogin';
- if (this.btn_type == 'reg') {
- method = '/Member/register';
- if (this.code.length < 4) {
- uni.showToast({
- title: '请输入验证码',
- icon: 'none'
- });
- return;
- }
- } else if (this.btn_type == 'reset') {
- method = '/Member/resetPass';
- if (this.code.length < 4) {
- uni.showToast({
- title: '请输入验证码',
- icon: 'none'
- });
- return;
- }
- }
- let channel = "";
- // #ifdef APP-PLUS
- channel = plus.runtime.channel;
- // #endif
- uni.showLoading({
- mask: true,
- });
- console.log("host", this.$apiHost + method);
- uni.request({
- url: this.$apiHost + method,
- data: {
- uuid: getApp().globalData.uuid,
- channel: channel,
- loginType: this.type,
- mobile: this.mobile,
- password: this.password,
- code: this.code,
- push_token: this.push_token,
- lat: this.lat,
- lng: this.lng,
- },
- header: {
- "content-type": "application/json",
- },
- success: (res) => {
- console.log("----", res.data);
- if (res.data.success == "yes") {
- console.log("res.data", res.data);
- uni.setStorageSync("wapptoken", res.data.skey);
- getApp().globalData.skey = res.data.skey;
- if (res.data.header_c != "") {
- getApp().globalData.headerSign = pubc.Encrypt(res.data.header_c + "_" +
- getApp().globalData.uuid);
- uni.setStorageSync("headerSign", getApp().globalData.headerSign);
- }
- getApp().globalData.headerC = res.data.header_c;
- if (res.data.nickname == '') {
- uni.redirectTo({
- url: '/pages/my/step'
- });
- return;
- }
- uni.switchTab({
- url: "/pages/index/index",
- });
- } else if (res.data.success == "no") {
- uni.showToast({
- title: res.data.str,
- icon: "none",
- });
- } else {
- uni.showToast({
- title: "操作失败,请联系客服",
- icon: "none",
- });
- }
- },
- complete: (com) => {
- uni.hideLoading();
- },
- });
- },
- getCode() {
- if (this.mobile.length != 11) {
- uni.showToast({
- title: '请输入手机号',
- icon: 'none'
- });
- return;
- }
- if (this.captchaTime > 0) {
- uni.showToast({
- title: '不能重复获取',
- icon: 'none'
- });
- return;
- }
- this.captchaTime = 60;
- uni.request({
- url: this.$apiHost + '/Web/getcode', //仅为示例,并非真实接口地址。
- data: {
- skey: this.skey,
- mobile: this.mobile,
- },
- header: {
- 'content-type': 'application/json' //自定义请求头信息
- },
- success: (res) => {
- console.log("----", res.data)
- uni.showToast({
- title: res.data.str,
- icon: 'none'
- })
- if (res.data.success == 'yes') {
- this.getCodeTime();
- } else {
- this.captchaTime = 0;
- }
- }
- });
- },
- }
- }
- </script>
- <style scoped lang="scss">
- @import 'login.scss';
- </style>
|