| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- <template>
- <!-- 登录 -->
- <view class="container flex-items-plus flex-column">
- <global-loading />
- <view class="login-logoBox">
- <image class="login-logo" src="../../static/images/origin/loginLogo.png"></image>
- </view>
- <view class="iphoneNum-box flex-row-plus flex-items">
- <view style="margin-right: 30rpx">
- <image class="loginIcon" src="../../static/images/origin/phone.png"></image>
- </view>
- <view>
- <input
- v-model="loginQuery.account" placeholder-class="iphoneNum-input" type="number" maxlength="11"
- placeholder="请输入您的手机号"
- />
- </view>
- </view>
- <view class="flex-row-plus mar-top-20">
- <view class="code-box">
- <view style="margin-right: 30rpx">
- <image class="loginIcon" src="../../static/images/origin/code.png"></image>
- </view>
- <view>
- <input v-model="loginQuery.code" :maxlength="4" placeholder-class="codeNum-input" placeholder="请输入验证码" />
- </view>
- </view>
- <view :class="disabled === true ? 'on' : ''" :disabled="disabled" class="getcode" @click="codede">
- {{ text }}
- </view>
- </view>
- <view class="mar-top-60">
- <view class="registerBut mar-top-100" @click="login">
- 登录
- </view>
- </view>
- </view>
- </template>
- <script>
- import sendVerifyCode from '@/mixins/SendVerifyCode'
- const NET = require('../../utils/request')
- const API = require('../../config/api')
- export default {
- mixins: [ sendVerifyCode ],
- data() {
- return {
- loginQuery: {
- account: '',
- code: '',
- salesId: ''
- },
- // 获取验证码
- VerifyQuery: {
- phone: ''
- },
- inviteSpell: {},
- inviteSpelltype: false,
- beforePage: undefined,
- doubleBeforePage: undefined
- }
- },
- onLoad(options) {
- if (options.inviteSpell == 1) {
- this.inviteSpelltype = true
- this.inviteSpell = uni.getStorageSync('inviteSpell')
- }
- this.loginQuery.salesId = uni.getStorageSync('salesId')
- var pages = getCurrentPages()
- if (pages.length >= 2) {
- this.beforePage = pages[pages.length - 2]
- }
- if (pages.length >= 3) {
- this.doubleBeforePage = pages[pages.length - 3]
- }
- },
- methods: {
- login() {
- const phoneCodeVerification = /^[1][3-9][0-9]{9}$/
- if (this.loginQuery.account == '') {
- uni.showToast({
- title: '请输入手机号!',
- duration: 2000,
- icon: 'none'
- })
- } else if (!phoneCodeVerification.test(this.loginQuery.account)) {
- uni.showToast({
- title: '请输入正确的手机号!',
- duration: 2000,
- icon: 'none'
- })
- } else {
- const that = this
- // uni.showLoading({
- // mask: true,
- // title: '正在登录...',
- // duration: 2000,
- // });
- NET.request(API.Login, {
- type: 2,
- phone: this.loginQuery.account,
- verificationCode: this.loginQuery.code
- }, 'POST').then((res) => {
- uni.hideLoading()
- const item = res.data
- uni.setStorageSync('storage_key', item)
- if (uni.getStorageSync('salesId')) {
- const salesId = uni.getStorageSync('salesId')
- const shopId = uni.getStorageSync('shopId')
- this.bindSalesCustomer(salesId, shopId)
- uni.removeStorageSync('salesId')
- uni.removeStorageSync('shopId')
- }
- // 购物车右上角数量
- NET.request(API.ShoppingCart, {}, 'GET').then((resCart) => {
- let cartNum = 0
- resCart.data.forEach((shopItem) => {
- shopItem.skus.forEach((goodsItem) => {
- cartNum += goodsItem.number
- })
- })
- if (cartNum > 0) {
- uni.setTabBarBadge({
- index: 2,
- text: cartNum.toString()
- })
- }
- uni.setStorageSync('allCartNum', cartNum)
- })
- if (this.inviteSpelltype == true) {
- setTimeout(function () {
- uni.reLaunch({
- url: '../../pages_category_page1/goodsModule/inviteSpell?collageId=' +
- this.inviteSpell.collageId + '&orderId=' + this.inviteSpell
- .orderId + '&type=0' + '&productId=' + this.inviteSpell
- .productId + '&skuId=' + this.inviteSpell.skuId
- })
- uni.removeStorageSync('inviteSpell')
- }, 2000)
- } else if (that.beforePage && that.beforePage.route !==
- 'pages_category_page2/userModule/accountLogin' &&
- that.beforePage.route !== 'pages_category_page2/userModule/login' &&
- that.beforePage.route !== 'pages_category_page2/userModule/register') {
- uni.navigateBack({
- delta: 1
- })
- } else if (that.doubleBeforePage && that.doubleBeforePage.route !==
- 'pages_category_page2/userModule/accountLogin' &&
- that.doubleBeforePage.route !== 'pages_category_page2/userModule/login' &&
- that.doubleBeforePage.route !== 'pages_category_page2/userModule/register') {
- uni.navigateBack({
- delta: 2
- })
- } else {
- setTimeout(function () {
- uni.switchTab({
- url: '../../pages/tabbar/user/index'
- })
- }, 600)
- }
- })
- .catch((res) => {
- console.dir(res)
- uni.hideLoading()
- uni.showToast({
- title: res.data.message,
- duration: 2000,
- icon: 'none'
- })
- })
- }
- },
- // 获取验证码
- codede() {
- this.getVerify()
- },
- getVerify() {
- const phoneCodeVerification = /^[1][3-9][0-9]{9}$/
- if (this.loginQuery.account == '') {
- uni.showToast({
- title: '请输入手机号!',
- duration: 2000,
- icon: 'none'
- })
- } else if (!phoneCodeVerification.test(this.loginQuery.account)) {
- uni.showToast({
- title: '请输入正确的手机号!',
- duration: 2000,
- icon: 'none'
- })
- } else {
- this.VerifyQuery.phone = this.loginQuery.account
- NET.request(API.Verify, {
- phone: this.VerifyQuery.phone
- }, 'GET').then((res) => {
- this.sendCode()
- })
- .catch((res) => {
- uni.showToast({
- title: res.data.message,
- duration: 1000,
- icon: 'none'
- })
- })
- }
- },
- // 绑定关系
- bindSalesCustomer(salesId, storeId) {
- if (salesId && storeId) {
- // 如果已登录,静默绑定客户关系,否则跳转到登录页面
- NET.request(API.BindSalesCustomer, {
- shopId: storeId,
- distributorId: salesId
- }, 'POST').then((res) => {
- uni.showToast({
- title: '绑定成功',
- icon: 'none'
- })
- })
- .catch((res) => {
- uni.showToast({
- title: res.data.message,
- icon: 'none'
- })
- })
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .container {
- background-color: #FFFFFF;
- height: 100vh;
- .login-logoBox {
- margin-top: -300rpx;
- .login-logo {
- width: 234rpx;
- height: 193rpx;
- }
- }
- .iphoneNum-box {
- margin-top: 100rpx;
- border-bottom: 1rpx solid #DDDDDD;
- height: 100rpx;
- width: 600rpx;
- .loginIcon {
- width: 40rpx;
- height: 53rpx;
- }
- .iphoneNum-input {
- color: #999999;
- font-size: 28rpx;
- font-weight: 400;
- }
- }
- .passwordNum-box {
- border-bottom: 1rpx solid #DDDDDD;
- height: 100rpx;
- width: 600rpx;
- .passwordNum-input {
- color: #999999;
- font-size: 28rpx;
- font-weight: 400;
- width: 346rpx;
- }
- }
- .code-box {
- border-bottom: 1rpx solid #DDDDDD;
- height: 100rpx;
- width: 360rpx;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- .loginIcon {
- width: 44rpx;
- height: 50rpx;
- }
- .code-lab {
- width: 200rpx;
- }
- .codeNum-input {
- color: #999999;
- font-size: 28rpx;
- font-weight: 400;
- }
- }
- .getcode {
- background-color: #C5AA7B;
- height: 100rpx;
- width: 230rpx;
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: center;
- margin-left: 20rpx;
- color: #FFFFFF;
- }
- .registerBut {
- background: #333333;
- color: #FFEBC4;
- height: 100rpx;
- width: 600rpx;
- text-align: center;
- line-height: 100rpx;
- margin-top: 30rpx;
- }
- }
- </style>
|