| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import Toast from '@vant/weapp/toast/toast';
- const _Http = getApp().globalData.http,
- loginMsg = require("./modules/login");
- let count = 0;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- loginFunc: true,
- isAgree: false,
- disabled: true, //是否禁用
- loading: false, //登陆中
- showChange: false
- },
- onLoad() {
- let accountInfo = wx.getAccountInfoSync();
- const ENV = accountInfo.miniProgram.envVersion
- if (ENV === 'release') { // 正式版
- console.log("正式")
- this.setData({
- loginFunc: true
- })
- } else { // 开发,测试
- this.setData({
- showChange: true,
- loginFunc: false
- })
- }
- },
- /* 微信登录 */
- wechatLogin() {
- if (!this.data.isAgree) return Toast({
- message: '请阅读并勾选用户协议',
- position: 'bottom'
- });
- wx.login({
- success(res) {
- if (res.code) {
- _Http.loginbywechat({
- wechat_code: res.code,
- "systemclient": "wechatsaletool"
- }).then(res => {
- console.log("微信快捷登录", res)
- if (res.code == 0) return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- loginMsg.loginMsg(res);
- })
- } else {
- console.log('登录失败!' + res.errMsg)
- }
- }
- })
- },
- /* 用户登录 */
- userLogin() {
- if (this.data.loading || this.data.disabled) return;
- if (!this.data.isAgree) return Toast({
- message: '请阅读并勾选用户协议',
- position: 'bottom'
- });
- this.setData({
- loading: true
- })
- this.selectComponent('#login').handleLogin();
- },
- changeLoginFun() {
- this.setData({
- loginFunc: !this.data.loginFunc
- })
- },
- /* 授权 */
- agreementChange({
- detail
- }) {
- this.setData({
- isAgree: detail
- })
- },
- openChange() {
- count += 1;
- if (count == 10) this.setData({
- showChange: true
- })
- },
- })
|