Authored by yyq

Merge branch 'develop' of git.yoho.cn:fe/yoho-brand-shop into develop

@@ -5,7 +5,6 @@ import {verify} from './common/api'; @@ -5,7 +5,6 @@ import {verify} from './common/api';
5 import config from './common/config'; 5 import config from './common/config';
6 import Promise from './vendors/es6-promise'; 6 import Promise from './vendors/es6-promise';
7 import { MD5 } from './vendors/crypto'; 7 import { MD5 } from './vendors/crypto';
8 -import { WeToast } from './vendors/toast/wetoast';  
9 import { wechatAuthLogin, verifySessionKey } from './common/login'; 8 import { wechatAuthLogin, verifySessionKey } from './common/login';
10 import { stringify } from './vendors/query-stringify'; 9 import { stringify } from './vendors/query-stringify';
11 import './router/index'; 10 import './router/index';
@@ -247,6 +246,5 @@ App({ @@ -247,6 +246,5 @@ App({
247 }, 246 },
248 getPvid() { 247 getPvid() {
249 return MD5(`${new Date().getTime()}${udid.get()}`).toString(); 248 return MD5(`${new Date().getTime()}${udid.get()}`).toString();
250 - },  
251 - WeToast 249 + }
252 }); 250 });
@@ -17,5 +17,4 @@ @@ -17,5 +17,4 @@
17 } 17 }
18 18
19 @import "./iconfont.wxss"; 19 @import "./iconfont.wxss";
20 -@import "./vendors/toast/wetoast.wxss";  
21 @import "./vendors/zanui/index.wxss"; 20 @import "./vendors/zanui/index.wxss";
@@ -7,34 +7,44 @@ import accountModel from '../models/account/index'; @@ -7,34 +7,44 @@ import accountModel from '../models/account/index';
7 * 用户未授权-发送验证码 7 * 用户未授权-发送验证码
8 * @param mobile 手机号 8 * @param mobile 手机号
9 * @param area 国家码 9 * @param area 国家码
  10 + * @param degrees 验证码
10 */ 11 */
11 -function sendVerifyCode(area, mobile) {  
12 - return accountModel.sendSms(area, mobile); 12 +function sendVerifyCode(area, mobile, degrees) {
  13 + return accountModel.sendSms(area, mobile, degrees);
13 } 14 }
14 15
15 /** 16 /**
16 * 用户已授权-发送验证码 17 * 用户已授权-发送验证码
17 * @param mobile 手机号 18 * @param mobile 手机号
18 * @param area 国家码 19 * @param area 国家码
  20 + * @param degrees 验证码
19 */ 21 */
20 -function sendVerifyCodeWithUnionId(area, mobile) {  
21 - return accountModel.sendCodeByMiniApp(area, mobile, getApp().getOpenID()); 22 +function sendVerifyCodeWithUnionId(area, mobile, degrees) {
  23 + return accountModel.sendCodeByMiniApp(area, mobile, getApp().getOpenID(), degrees);
  24 +}
  25 +
  26 +/**
  27 + * 是否需要验证码
  28 + */
  29 +function isNeedImgCheck() {
  30 + return accountModel.isNeedImgCheck();
22 } 31 }
23 32
24 /** 33 /**
25 * 获取验证码按钮 34 * 获取验证码按钮
26 * @param area 35 * @param area
27 * @param mobile 36 * @param mobile
  37 + * @param degrees 验证码
28 * @returns {*} 38 * @returns {*}
29 */ 39 */
30 -function getVerifyCode(area, mobile) { 40 +function getVerifyCode(area, mobile, degrees) {
31 let app = getApp(); 41 let app = getApp();
32 42
33 if (!app.globalData.unionID) { 43 if (!app.globalData.unionID) {
34 - return sendVerifyCode(area, mobile); 44 + return sendVerifyCode(area, mobile, degrees);
35 } 45 }
36 46
37 - return sendVerifyCodeWithUnionId(area, mobile); 47 + return sendVerifyCodeWithUnionId(area, mobile, degrees);
38 } 48 }
39 49
40 /** 50 /**
@@ -338,6 +348,7 @@ function getPhoneNumber(e) { @@ -338,6 +348,7 @@ function getPhoneNumber(e) {
338 348
339 export { 349 export {
340 wechatAuthLogin, 350 wechatAuthLogin,
  351 + isNeedImgCheck,
341 getVerifyCode, 352 getVerifyCode,
342 bindMobileAction, 353 bindMobileAction,
343 tapToLogin, 354 tapToLogin,
  1 +import udid from '../../common/udid';
  2 +import config from '../../common/config';
  3 +
  4 +Component({
  5 + /**
  6 + * 组件的初始数据
  7 + */
  8 + data: {
  9 + imageSrc: '',
  10 + degrees: [0, 0, 0, 0],
  11 + imageClass: [0, 0, 0, 0]
  12 + },
  13 +
  14 + attached: function () {
  15 + this.setData({
  16 + imageSrc: this.getVerifyImage()
  17 + });
  18 + },
  19 +
  20 + /**
  21 + * 组件的方法列表
  22 + */
  23 + methods: {
  24 + /**
  25 + * 获取图片
  26 + */
  27 + getVerifyImage: function () {
  28 + let timestamp = Date.parse(new Date());
  29 + let url = `${config.domains.api}/passport/img-check?business_line=${config.apiParams.business_line}&app_version=0.0.1&udid=${udid.get()}&client_type=${config.apiParams.client_type}&fromPage=${config.apiParams.client_type}&t=${timestamp}`;
  30 +
  31 + return url;
  32 + },
  33 +
  34 + /**
  35 + * 更新图片
  36 + */
  37 + refreshImage: function () {
  38 + this.setData({
  39 + imageSrc: this.getVerifyImage()
  40 + });
  41 + },
  42 +
  43 + /**
  44 + * 改变图片的方向
  45 + */
  46 + changeDirection: function (event) {
  47 + let indexNum = event.currentTarget.id.replace('image-', '');
  48 + let degrees = this.data.degrees;
  49 + let imageClass = this.data.imageClass;
  50 +
  51 + degrees[indexNum] = (degrees[indexNum] + 1) % 4;
  52 + imageClass[indexNum] = (imageClass[indexNum] + 140) % 560;
  53 +
  54 + this.setData({
  55 + degrees: degrees,
  56 + imageClass: imageClass
  57 + });
  58 + this.triggerEvent('refreshCode', {
  59 + degrees: this.data.degrees
  60 + });
  61 + }
  62 + }
  63 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<view class="top-box">
  2 + <text class="tip">请将下列图片点击翻转至正向朝上</text>
  3 + <text class="refresh" bindtap="refreshImage">换一批</text>
  4 +</view>
  5 +<view class="image-check-box">
  6 + <view class="image-box">
  7 + <image class="image image-0 image-margin-{{imageClass[0]}}" src="{{imageSrc}}" bindtap="changeDirection"
  8 + id="image-0"></image>
  9 + </view>
  10 + <view class="image-box">
  11 + <image class="image image-1 image-margin-{{imageClass[1]}}" src="{{imageSrc}}" bindtap="changeDirection"
  12 + id="image-1"></image>
  13 + </view>
  14 + <view class="image-box">
  15 + <image class="image image-2 image-margin-{{imageClass[2]}}" src="{{imageSrc}}" bindtap="changeDirection"
  16 + id="image-2"></image>
  17 + </view>
  18 + <view class="image-box">
  19 + <image class="image image-3 image-margin-{{imageClass[3]}}" src="{{imageSrc}}" bindtap="changeDirection"
  20 + id="image-3"></image>
  21 + </view>
  22 +</view>
  1 +.top-box {
  2 + margin-bottom: 20rpx;
  3 + display: flex;
  4 + justify-content: space-between;
  5 +}
  6 +
  7 +.tip {
  8 + color: #444;
  9 + font-size: 28rpx;
  10 +}
  11 +
  12 +.refresh {
  13 + font-size: 28rpx;
  14 + color: #d0021b;
  15 +}
  16 +
  17 +.image-check-box {
  18 + display: flex;
  19 + flex-direction: row;
  20 + flex-wrap: nowrap;
  21 + justify-content: space-between;
  22 +}
  23 +
  24 +.image-box {
  25 + width: 140rpx;
  26 + height: 140rpx;
  27 + overflow: hidden;
  28 + border: solid 1px #e0e0e0;
  29 +}
  30 +
  31 +.image {
  32 + width: 560rpx;
  33 + height: 560rpx;
  34 +}
  35 +
  36 +.image-0 {
  37 + margin-left: 0;
  38 +}
  39 +
  40 +.image-1 {
  41 + margin-left: -140rpx;
  42 +}
  43 +
  44 +.image-2 {
  45 + margin-left: -280rpx;
  46 +}
  47 +
  48 +.image-3 {
  49 + margin-left: -420rpx;
  50 +}
  51 +
  52 +.image-margin-140 {
  53 + margin-top: -140rpx;
  54 +}
  55 +
  56 +.image-margin-280 {
  57 + margin-top: -280rpx;
  58 +}
  59 +
  60 +.image-margin-420 {
  61 + margin-top: -420rpx;
  62 +}
@@ -186,15 +186,18 @@ export default { @@ -186,15 +186,18 @@ export default {
186 * 用户未授权-发送验证码 186 * 用户未授权-发送验证码
187 * @param area 国家码 187 * @param area 国家码
188 * @param mobile 手机号 188 * @param mobile 手机号
  189 + * @param degrees 验证码
189 * @returns {*} 190 * @returns {*}
190 */ 191 */
191 - sendSms(area, mobile) { 192 + sendSms(area, mobile, degrees) {
192 return api.get({ 193 return api.get({
193 url: '', 194 url: '',
194 data: { 195 data: {
195 area, 196 area,
196 mobile, 197 mobile,
  198 + degrees,
197 source_type: 'wechat', 199 source_type: 'wechat',
  200 + fromPage: 'miniapp',
198 method: 'app.message.sendSms' 201 method: 'app.message.sendSms'
199 } 202 }
200 }); 203 });
@@ -204,18 +207,31 @@ export default { @@ -204,18 +207,31 @@ export default {
204 * 用户已授权-发送验证码 207 * 用户已授权-发送验证码
205 * @param mobile 手机号 208 * @param mobile 手机号
206 * @param area 国家码 209 * @param area 国家码
  210 + * @param openId
  211 + * @param degrees 验证码
207 * @returns {*} 212 * @returns {*}
208 */ 213 */
209 - sendCodeByMiniApp(area, mobile, openId) { 214 + sendCodeByMiniApp(area, mobile, openId, degrees) {
210 return api.get({ 215 return api.get({
211 url: '', 216 url: '',
212 data: { 217 data: {
213 area, 218 area,
214 mobile, 219 mobile,
  220 + degrees,
215 open_id: openId, 221 open_id: openId,
216 source_type: 'wechat', 222 source_type: 'wechat',
217 - method: 'app.bind.sendCodeByMiniApp' 223 + fromPage: 'miniapp',
  224 + method: 'app.bind.sendThirdBindMobileCodeOnlyImg'
218 } 225 }
219 }); 226 });
  227 + },
  228 +
  229 + /**
  230 + * 是否需要验证码
  231 + */
  232 + isNeedImgCheck(udid) {
  233 + return api.get({
  234 + url: '/smart/way',
  235 + });
220 } 236 }
221 }; 237 };
1 import wx from '../../utils/wx'; 1 import wx from '../../utils/wx';
2 import event from '../../common/event'; 2 import event from '../../common/event';
3 import Yas from '../../common/yas'; 3 import Yas from '../../common/yas';
4 -import {getVerifyCode, bindMobileAction} from '../../common/login'; 4 +import { getVerifyCode, bindMobileAction, isNeedImgCheck} from '../../common/login';
5 5
6 let app = getApp(); 6 let app = getApp();
7 let router = global.router; 7 let router = global.router;
@@ -12,6 +12,7 @@ Page({ @@ -12,6 +12,7 @@ Page({
12 areaCode: '86', 12 areaCode: '86',
13 phoneNum: '', 13 phoneNum: '',
14 smsCode: '', 14 smsCode: '',
  15 + degrees: '0,0,0,0',
15 btnText: '获取验证码', 16 btnText: '获取验证码',
16 timerSec: 60, 17 timerSec: 60,
17 counting: false, 18 counting: false,
@@ -21,7 +22,8 @@ Page({ @@ -21,7 +22,8 @@ Page({
21 areaName: '中国', 22 areaName: '中国',
22 hasUnionID: false, 23 hasUnionID: false,
23 isSubmitting: false, 24 isSubmitting: false,
24 - autoBtnText: '自动验证' 25 + autoBtnText: '自动验证',
  26 + isNeedImgCheck: false
25 }, 27 },
26 onLoad: function(query) { 28 onLoad: function(query) {
27 const {phone, area} = query || {}; 29 const {phone, area} = query || {};
@@ -50,6 +52,17 @@ Page({ @@ -50,6 +52,17 @@ Page({
50 hasUnionID: !!app.globalData.unionID 52 hasUnionID: !!app.globalData.unionID
51 }); 53 });
52 54
  55 + isNeedImgCheck().then(result => {
  56 + if (result.code === 200) {
  57 + this.setData({
  58 + isNeedImgCheck: result.data
  59 + });
  60 + } else {
  61 + this.setData({
  62 + isNeedImgCheck: true
  63 + });
  64 + }
  65 + });
53 yas.pageOpenReport(); 66 yas.pageOpenReport();
54 }, 67 },
55 phoneInput: function(e) { 68 phoneInput: function(e) {
@@ -71,7 +84,7 @@ Page({ @@ -71,7 +84,7 @@ Page({
71 } 84 }
72 85
73 if (this.checkPhoneFormat()) { 86 if (this.checkPhoneFormat()) {
74 - return getVerifyCode(this.data.areaCode, this.data.phoneNum).then(res => { 87 + return getVerifyCode(this.data.areaCode, this.data.phoneNum, this.data.degrees).then(res => {
75 if (res.code === 200) { 88 if (res.code === 200) {
76 this.countDown(); 89 this.countDown();
77 } else { 90 } else {
@@ -217,5 +230,13 @@ Page({ @@ -217,5 +230,13 @@ Page({
217 }, 230 },
218 chooseArea: function() { 231 chooseArea: function() {
219 router.go('chooseArea'); 232 router.go('chooseArea');
  233 + },
  234 + /**
  235 + * 监听验证码组件
  236 + */
  237 + onRefreshCode: function(event) {
  238 + this.setData({
  239 + degrees: event.detail.degrees.join(',')
  240 + });
220 } 241 }
221 }); 242 });
1 { 1 {
2 - "navigationBarTitleText": "验证手机号" 2 + "navigationBarTitleText": "验证手机号",
  3 + "usingComponents": {
  4 + "image-check": "/components/image-check/image-check"
  5 + }
3 } 6 }
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 placeholder="请输入验证码"></input> 16 placeholder="请输入验证码"></input>
17 <span class="{{'send-code ' + activeClass}}" bindtap="sendCode">{{btnText}}</span> 17 <span class="{{'send-code ' + activeClass}}" bindtap="sendCode">{{btnText}}</span>
18 </view> 18 </view>
  19 + <image-check wx:if="{{isNeedImgCheck}}" class="image-check" bindrefreshCode="onRefreshCode"></image-check>
19 <view bindtap="submitTap" class="{{'btn confirm ' + completeClass}}">完成</view> 20 <view bindtap="submitTap" class="{{'btn confirm ' + completeClass}}">完成</view>
20 <button wx:if="{{false}}" class="btn auto-bind" bindtap="{{!hasUnionID ? 'autoVerify' : ''}}" 21 <button wx:if="{{false}}" class="btn auto-bind" bindtap="{{!hasUnionID ? 'autoVerify' : ''}}"
21 open-type="{{hasUnionID ? 'getPhoneNumber' : ''}}" 22 open-type="{{hasUnionID ? 'getPhoneNumber' : ''}}"
@@ -135,3 +135,7 @@ @@ -135,3 +135,7 @@
135 background-color: #444; 135 background-color: #444;
136 } 136 }
137 137
  138 +.bind-mobile .image-check {
  139 + display: block;
  140 + margin-top: 20rpx;
  141 +}
@@ -335,13 +335,6 @@ Page({ @@ -335,13 +335,6 @@ Page({
335 335
336 this.shopRecList(res.data.shop_id); 336 this.shopRecList(res.data.shop_id);
337 } 337 }
338 - })  
339 - .catch(function (error) {  
340 - this.wetoast.toast({  
341 - title: error.code + error.message + '',  
342 - titleClassName: 'wetoast-title',  
343 - duration: 1000  
344 - });  
345 }); 338 });
346 }, 339 },
347 supportService: function () { 340 supportService: function () {
@@ -468,10 +461,10 @@ Page({ @@ -468,10 +461,10 @@ Page({
468 } 461 }
469 462
470 if (tempItem.storage_number <= 0) { 463 if (tempItem.storage_number <= 0) {
471 - this.wetoast.toast({ 464 + wx.showToast({
472 title: '该尺码已经售罄', 465 title: '该尺码已经售罄',
473 - titleClassName: 'wetoast-title',  
474 - duration: 1000 466 + icon: 'none',
  467 + duration: 2000
475 }); 468 });
476 469
477 pickData.view.buyButtonEnable = false 470 pickData.view.buyButtonEnable = false
1 -/**  
2 - * WeToast by kiinlam  
3 - * WeApp Toast add-ons  
4 - * 微信小程序toast增强插件  
5 - * Github: https://github.com/kiinlam/wetoast  
6 - * LICENSE: MIT  
7 - */  
8 -  
9 -function WeToastClass () {  
10 -  
11 - //构造函数  
12 - function WeToast () {  
13 - let pages = getCurrentPages()  
14 - let curPage = pages[pages.length - 1]  
15 - this.__page = curPage  
16 - this.__timeout = null  
17 -  
18 - //附加到page上,方便访问  
19 - curPage.wetoast = this  
20 -  
21 - return this  
22 - }  
23 -  
24 - //切换显示/隐藏  
25 - WeToast.prototype.toast = function(data) {  
26 - try {  
27 - if (!data) {  
28 - this.hide()  
29 - } else {  
30 - this.show(data)  
31 - }  
32 - } catch (err) {  
33 - // console.error(err)  
34 -  
35 - // fail callback  
36 - data && typeof data.fail === 'function' && data.fail(data)  
37 - } finally {  
38 - // complete callback  
39 - data && typeof data.complete === 'function' && data.complete(data)  
40 - }  
41 - }  
42 -  
43 - //显示  
44 - WeToast.prototype.show = function(data) {  
45 - let page = this.__page  
46 -  
47 - clearTimeout(this.__timeout)  
48 -  
49 - //display需要先设置为block之后,才能执行动画  
50 - page.setData({  
51 - '__wetoast__.reveal': true  
52 - })  
53 -  
54 - setTimeout(()=>{  
55 - let animation = wx.createAnimation()  
56 - animation.opacity(1).step()  
57 - data.animationData = animation.export()  
58 - data.reveal = true  
59 - page.setData({  
60 - __wetoast__: data  
61 - })  
62 - },30)  
63 -  
64 - if (data.duration === 0) {  
65 - // success callback after toast showed  
66 - setTimeout (() => {  
67 - typeof data.success === 'function' && data.success(data)  
68 - }, 430)  
69 - } else {  
70 - this.__timeout = setTimeout(() => {  
71 - this.toast()  
72 -  
73 - // success callback  
74 - typeof data.success === 'function' && data.success(data)  
75 - }, (data.duration || 1500) + 400)  
76 - }  
77 -  
78 - }  
79 -  
80 - //隐藏  
81 - WeToast.prototype.hide = function() {  
82 - let page = this.__page  
83 -  
84 - clearTimeout(this.__timeout)  
85 -  
86 - if (!page.data.__wetoast__.reveal) {  
87 - return  
88 - }  
89 -  
90 - let animation = wx.createAnimation()  
91 - animation.opacity(0).step()  
92 - page.setData({  
93 - '__wetoast__.animationData': animation.export()  
94 - })  
95 -  
96 - setTimeout(() => {  
97 - page.setData({  
98 - __wetoast__: {'reveal': false}  
99 - })  
100 - }, 400)  
101 - }  
102 -  
103 - return new WeToast()  
104 -}  
105 -  
106 -module.exports = {  
107 - WeToast: WeToastClass  
108 -}  
1 -<!-- wetoast.wxml -->  
2 -<template name="wetoast">  
3 - <view class="wetoast {{reveal ? 'wetoast_show' : ''}}">  
4 - <view class="wetoast__mask"></view>  
5 - <view class="wetoast__bd" animation="{{animationData}}">  
6 - <block wx:if="{{img}}">  
7 - <view class="wetoast__bd__img {{imgClassName || ''}}">  
8 - <image class="wetoast__bd__img_desc" src="{{img}}" mode="{{imgMode || 'scaleToFill'}}"></image>  
9 - </view>  
10 - </block>  
11 - <block wx:if="{{title}}">  
12 - <view class="wetoast__bd__title {{titleClassName || ''}}">{{title}}</view>  
13 - </block>  
14 - </view>  
15 - </view>  
16 -</template>  
1 -/**toast.wxss**/  
2 -.wetoast {  
3 - display: none;  
4 -}  
5 -.wetoast_show {  
6 - display: block;  
7 -}  
8 -.wetoast__mask {  
9 - position: fixed;  
10 - z-index: 1000;  
11 - top: 0;  
12 - right: 0;  
13 - left: 0;  
14 - bottom: 0;  
15 -}  
16 -.wetoast__bd {  
17 - opacity: 0;  
18 - display: flex;  
19 - flex-direction: column;  
20 - position: fixed;  
21 - z-index: 5000;  
22 - /*min-width: 8.4em;  
23 - min-height: 8.4em;*/  
24 - max-width: 70%;  
25 - top: 140px;  
26 - left: 50%;  
27 - padding: 15px;  
28 - box-sizing: border-box;  
29 - transform: translateX(-50%);  
30 - background: rgba(40, 40, 40, 0.75);  
31 - border-radius: 5px;  
32 - color: #FFFFFF;  
33 - word-wrap: break-word;  
34 - word-break: break-all;  
35 - align-items: center;  
36 - justify-content: space-around;  
37 -}  
38 -.wetoast__bd__img {  
39 - margin-top: 3px;  
40 -}  
41 -.wetoast__bd__img_desc {  
42 - width: 55px;  
43 - height: 55px;  
44 - vertical-align: middle;  
45 -}  
46 -.wetoast__bd__title {  
47 - margin: 3px 0;  
48 - font-size: 1.2em;  
49 - text-align: center;  
50 -}  
51 -  
52 -.wetoast-title {  
53 - font-size: 28rpx;  
54 -}