Authored by QC-L

扫码组件展示登录

... ... @@ -30,7 +30,7 @@
"list": []
},
"miniprogram": {
"current": 12,
"current": 14,
"list": [
{
"id": -1,
... ... @@ -117,6 +117,13 @@
"pathName": "pages/order/orderSuccess/orderSuccess",
"query": "",
"scene": "1011"
},
{
"id": -1,
"name": "扫码登录",
"pathName": "pages/productDetail/index",
"query": "q=https%3A%2F%2Fo.yohobuy.com%2Fufo%3Fp%3D517449%2C1%26skup%3D517449%26skn%3D10003791&scancode_time=1553151155",
"scene": 1011
}
]
}
... ...
// src/components/login/login-bg/login-bg.js
import { getLoginButtonType } from '../../../libs/login/login.js'
import event from '../../../utils/event.js'
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
loginText: '微信登录',
loginButtonType: '',
loginTips: ''
},
created() {
let that = this;
event.one('user-login-success', () => {
this.triggerEvent('loginSuccess', true);
// 返回上一页
this.goReferer(); // 如果不需要绑定手机则返回前一页
});
event.one('change-login-status', params => {
that.setData({
loginText: params.text || '微信登录',
loginTips: params.tips || '',
loginButtonType: params.openType || ''
});
});
event.one('user-login-callback', this.loginCallback);
event.one('user-get-phonenumber-error', this.getPhonenumberError);
},
attached() {
const buttonType = getLoginButtonType();
console.log(buttonType);
this.setData({
loginButtonType: buttonType
});
},
/**
* 组件的方法列表
*/
methods: {
loginCallback(res) {
},
goReferer() {
console.log('执行返回');
wx.navigateBack({
delta: 1
});
},
getPhonenumberError(error) {
if (error === 'getPhoneNumber:fail user deny') {
error = '获取手机号失败, 请使用验证码登录';
}
let timeOut = 1000;
if (error === 'getUserInfo:fail auth deny') {
timeOut = 0;
}
setTimeout(() => {
wx.navigateTo({
url: `../login/index`,
})
}, timeOut);
wx.showToast({
title: error,
duration: 3000,
icon: 'none'
});
},
}
})
... ...
{
"component": true,
"usingComponents": {
"login-button": "../button"
}
}
\ No newline at end of file
... ...
<!--src/components/login/login-bg/login-bg.wxml-->
<view class="login-container">
<image class="logo" src="../../../assets/images/home-logo.png"></image>
<view class="login-buttons">
<view class="to-login">{{loginText}}</view>
<login-button class="login-area auto-btn" openType="{{loginButtonType}}"></login-button>
</view>
<view class="login-tips">{{loginTips}}</view>
</view>
... ...
/* src/components/login/login-bg/login-bg.wxss */
.login-container {
position: fixed;
top: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
background-color: white;
}
.logo {
position: relative;
width: 366rpx;
height: 312rpx;
margin-top: 244rpx;
}
.login-buttons {
position: relative;
width: 540rpx;
height: 88rpx;
margin-top: 202rpx;
}
.login-area {
position: absolute;
top: 0;
left: 0;
width: 540rpx;
height: 88rpx;
}
.login-area.auto-btn {
background-color: transparent;
border: none;
}
.login-area.auto-btn:after {
border: none;
}
.login-tips {
width: 540rpx;
height: 60rpx;
line-height: 60rpx;
font-size: 24rpx;
color: #b0b0b0;
margin-top: 16rpx;
text-align: center;
}
.to-login {
height: 100%;
line-height: 88rpx;
color: #fff;
font-size: 32rpx;
letter-spacing: 8rpx;
text-align: center;
background-color: #000;
border-radius: 50rpx;
}
... ...
... ... @@ -68,6 +68,7 @@ Page({
goReferer() {
console.log('执行返回');
// 隐藏登录
wx.navigateBack({
delta: 1
});
... ...
import Taro, {Component} from '@tarojs/taro';
import Taro, {Component, login} from '@tarojs/taro';
import {View, Swiper, SwiperItem, Image} from '@tarojs/components';
import {productDetail as productDetailModel} from '../../models';
import {getImgUrl} from '../../utils';
... ... @@ -56,6 +56,7 @@ export default class ProductDetail extends Component {
snapshootShareData: {},
skup: '',
storeId: -1,
isLogin: true,
productDec: {
color: {
text: '颜色',
... ... @@ -84,7 +85,8 @@ export default class ProductDetail extends Component {
config = {
usingComponents: {
'share-sheet' : '../../components/shareSheet/shareSheet',
'snapshoot-share' : '../../components/shareSheet/snapshootShare/snapshootShare'
'snapshoot-share' : '../../components/shareSheet/snapshootShare/snapshootShare',
'login-bg': '../../components/login/login-bg/login-bg'
}
}
... ... @@ -142,14 +144,36 @@ export default class ProductDetail extends Component {
skup,
storeId
});
event.emit('user-is-login', () => {
this.loadStoreProductInfo(skup, storeId);
}, () => {
Taro.redirectTo({
url: `/pages/productDetail/index?skup=${skup}&storeId=${storeId}`,
});
});
// event.emit('user-is-login', () => {
// this.loadStoreProductInfo(skup, storeId);
// }, () => {
// Taro.redirectTo({
// url: `/pages/productDetail/index?skup=${skup}&storeId=${storeId}`,
// });
// });
event.emit('judge-user-is-login', this.isLogined.bind(this), this.isLoginCallBack.bind(this, skup, storeId));
}
isLogined(isLogin) {
this.setState({
isLogin
})
console.log(isLogin);
console.log(this.state.storeId);
}
isLoginCallBack(skup, storeId) {
this.loadStoreProductInfo(skup, storeId);
}
loginSuccess(isLogin) {
this.setState({
isLogin
})
let { skup, storeId } = this.state;
this.loadStoreProductInfo(skup, storeId);
}
async loadStoreProductInfo(skup, storeId) {
await getPrivateKey();
productDetailModel.getStoreProductDetail(skup, storeId).then(res => {
... ... @@ -495,12 +519,13 @@ export default class ProductDetail extends Component {
}
render() {
let {productInfo, recommendList, goodsList, productDec, id, skup} = this.state;
let {productInfo, recommendList, goodsList, productDec, id, skup, isLogin, storeId} = this.state;
let imageList = goodsList.image_list || [];
let status = productInfo.status;
return (
<View className="product-page">
<View>
{ !(!isLogin && storeId !== -1) && (<View className="product-page">
<View className="swiperNum">{this.swiperNum}</View>
<Swiper className='product-swiper' autoplay onChange={this.onChangeSwiper}>
{
... ... @@ -614,7 +639,12 @@ export default class ProductDetail extends Component {
{
skup ? <Image className="goYohoBuy" onClick={this.goOnLineProuduct.bind(this, id)} src={goOnLine} mode="aspectFill" /> : <Image className="goYohoBuy" onClick={this.goYohoBuyMinApp.bind(this)} src={goYohoBuy} mode="aspectFill" />
}
</View>
</View>)
}
{
!isLogin && storeId !== -1 && (<login-bg catchtouchmove='true' onLoginSuccess={this.loginSuccess}></login-bg>)
}
</View>
)
}
}
... ...
... ... @@ -1883,10 +1883,6 @@ constants-browserify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75"
contains-path@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a"
content-disposition@0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4"
... ... @@ -2349,13 +2345,6 @@ dns-txt@^2.0.2:
dependencies:
buffer-indexof "^1.0.0"
doctrine@1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
dependencies:
esutils "^2.0.2"
isarray "^1.0.0"
doctrine@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
... ... @@ -2526,35 +2515,6 @@ eslint-config-taro@^1.1.0:
dependencies:
eslint-plugin-taro "1.1.0"
eslint-import-resolver-node@^0.3.1:
version "0.3.2"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a"
dependencies:
debug "^2.6.9"
resolve "^1.5.0"
eslint-module-utils@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz#b270362cd88b1a48ad308976ce7fa54e98411746"
dependencies:
debug "^2.6.8"
pkg-dir "^1.0.0"
eslint-plugin-import@^2.12.0:
version "2.14.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.14.0.tgz#6b17626d2e3e6ad52cfce8807a845d15e22111a8"
dependencies:
contains-path "^0.1.0"
debug "^2.6.8"
doctrine "1.5.0"
eslint-import-resolver-node "^0.3.1"
eslint-module-utils "^2.2.0"
has "^1.0.1"
lodash "^4.17.4"
minimatch "^3.0.3"
read-pkg-up "^2.0.0"
resolve "^1.6.0"
eslint-plugin-react@^7.8.2:
version "7.11.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.11.1.tgz#c01a7af6f17519457d6116aa94fc6d2ccad5443c"
... ... @@ -2900,7 +2860,7 @@ find-up@^1.0.0:
path-exists "^2.0.0"
pinkie-promise "^2.0.0"
find-up@^2.0.0, find-up@^2.1.0:
find-up@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
dependencies:
... ... @@ -4119,15 +4079,6 @@ load-json-file@^1.0.0:
pinkie-promise "^2.0.0"
strip-bom "^2.0.0"
load-json-file@^2.0.0:
version "2.0.0"
resolved "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
dependencies:
graceful-fs "^4.1.2"
parse-json "^2.2.0"
pify "^2.0.0"
strip-bom "^3.0.0"
loader-runner@^2.3.0:
version "2.3.1"
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.1.tgz#026f12fe7c3115992896ac02ba022ba92971b979"
... ... @@ -4482,7 +4433,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"
minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.2:
minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@~3.0.2:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
... ... @@ -5160,12 +5111,6 @@ path-type@^1.0.0:
pify "^2.0.0"
pinkie-promise "^2.0.0"
path-type@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
dependencies:
pify "^2.0.0"
path-type@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f"
... ... @@ -5204,12 +5149,6 @@ pinkie@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
pkg-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4"
dependencies:
find-up "^1.0.0"
pkg-dir@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b"
... ... @@ -5525,13 +5464,6 @@ read-pkg-up@^1.0.1:
find-up "^1.0.0"
read-pkg "^1.0.0"
read-pkg-up@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be"
dependencies:
find-up "^2.0.0"
read-pkg "^2.0.0"
read-pkg@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28"
... ... @@ -5540,14 +5472,6 @@ read-pkg@^1.0.0:
normalize-package-data "^2.3.2"
path-type "^1.0.0"
read-pkg@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8"
dependencies:
load-json-file "^2.0.0"
normalize-package-data "^2.3.2"
path-type "^2.0.0"
"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6:
version "2.3.6"
resolved "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
... ... @@ -5822,7 +5746,7 @@ resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
resolve@^1.1.6, resolve@^1.5.0, resolve@^1.6.0:
resolve@^1.1.6, resolve@^1.6.0:
version "1.8.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
dependencies:
... ... @@ -6384,10 +6308,6 @@ strip-bom@^2.0.0:
dependencies:
is-utf8 "^0.2.0"
strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
strip-eof@^1.0.0:
version "1.0.0"
resolved "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
... ...