2d22b076 by simon

1.加扫码功能 2.修复bug

1 parent 80e76f2b
......@@ -10,6 +10,6 @@
<view wx:if="{{item.commodityType == 'packet'}}" class="tips">
后台审核通过后,红包将会通过公众号消息或微信服务消息发送,届时请及时领取!
</view>
<view wx:else class="tips">您可以在“个人中心→我的订单”中查看物流进度</view>
<view wx:else class="tips">您可以在“礼物兑换→我的订单”中查看物流进度</view>
</view>
</view>
......
......@@ -8,20 +8,20 @@
.cont {
background: #FFFFFF;
@extend .shadow;
width: 670px;
width: 640px;
margin: 0 auto;
min-height: 900px;
@extend .bb;
padding: 20px 30px 20px;
.tit {
font-size: 40px;
font-size: 36px;
text-align: center;
}
.img-wrap {
$imgWidth: 610px;
$imgHeight: 480px;
$imgWidth: 580px;
$imgHeight: 580px;
margin: 20px 0;
width: $imgWidth;
height: $imgHeight;
......@@ -42,16 +42,15 @@
.desc {
color: #333333;
font-size: 28px;
height: 320px;
height: 230px;
line-height: 48px;
}
}
.close {
width: 82px;
height: 112px;
margin: 0 auto 40px;
margin: 0 auto 24px;
.btn {
width: 82px;
......
......@@ -11,6 +11,7 @@ function wxLogin() {
success: function (res) {
// isWxLogin = true;
Store.setItem('wxcode', res.code);
console.log("wxLogin code:", res.code);
resolve();
}
});
......@@ -68,6 +69,7 @@ function login() {
wx.login({
success: function (res) {
Store.setItem('wxcode', res.code);
console.log("auth code:", res.code);
view.showAuth();
}
});
......
......@@ -16,11 +16,11 @@ Page({
onReady() {
// app.store.clear("sessionId");
let _this = this;
wx.login({
success: function (res) {
_this.data.loginData = res;
}
});
// wx.login({
// success: function (res) {
// _this.data.loginData = res;
// }
// });
},
bindGetUserInfo(e) {
wx.showLoading();
......
......@@ -119,7 +119,7 @@ Page({
wx.showModal({
title: '兑换确认',
content: `将花费${item.commodityPrice}兑换${item.commodityTitle}一份`,
content: `将花费${item.commodityPrice}积分兑换${item.commodityTitle}一份`,
success(res) {
if (res.confirm) {
app.post({
......
......@@ -42,7 +42,7 @@
<view class="label">收货地址</view>
<view class="cont">{{defaultReceiver.receiverAddress}}</view>
</view>
<textarea value="{{remark}}" bindinput="bindRemarkInput" placeholder="备注您的其他要求" class="form-remark"></textarea>
<textarea wx:if="{{!orderSubmitSuccessCompVisible && !commonTipsCompVisible}}" value="{{remark}}" bindinput="bindRemarkInput" placeholder="备注您的其他要求" class="form-remark"></textarea>
</view>
<!-- 添加地址按钮 -->
<view wx:else bindtap="onAddressAddHandler" class="manage-add">我的收货地址</view>
......
import {
getBindtapData
getBindtapData,
getQueryByUrl
} from '../../utils/util';
let app = getApp();
......@@ -15,7 +16,9 @@ Page({
curProductDetail: {}, // 选中的产品详情
qrCodeCode: "",
userInfo: {}, //用户信息
code: "", // 手输入码
code: "", // 手输入码 / 扫出的积分码
memberCode: "", // 扫出的用户码
// integralCode: "", // 扫出的积分码
},
onShareAppMessage() {},
showAuth() {
......@@ -24,30 +27,48 @@ Page({
})
},
onLoad(options) {
let q = decodeURIComponent(options.q);
if (q) {
// 获取会员码
let m = getQueryByUrl("m", q);
if (m) {
this.setData({
memberCode: m
})
}
// 获取积分码
let c = getQueryByUrl("c", q);
if (c) {
this.setData({
code: c
})
}
}
this.queryProduct();
this.queryBanner();
let scene = decodeURIComponent(options.scene) || "";
// scene = "ab4cbd54dcf04d29a6c23d00a900b332"
if (scene) {
this.setData({
scene
})
}
this.initData();
},
onShow() {
console.log("onShow memberCode:", this.data.memberCode);
console.log("onShow code:", this.data.code);
},
initData() {
let {
scene
memberCode,
code
} = this.data;
if (scene) {
// 可能要拉授权
this.queryMember().then((result) => {
this.queryScanPersonQrcode().then((result) => {}).catch((err) => {});
// 如果存在扫码参数,则需要拉用户身份(未授权的情况下 要拉授权)
this.queryMember().then((result) => {
this.queryScanPersonQrcode().then((result2) => {
if (code) {
this.onSearchHandler();
}
});
}
});
},
......@@ -127,24 +148,25 @@ Page({
/**
* 扫个人码
* 如果没有码,直接返回
*/
queryScanPersonQrcode() {
return new Promise((resolve, reject) => {
let {
scene
memberCode
} = this.data;
if (scene) {
if (memberCode) {
app.post({
toast: false,
url: app.api.scanPersonQrcode,
data: {
memberCode: scene
memberCode: memberCode
}
}).then((result) => {
this.setData({
prizeInfo: result
})
resolve();
})
} else {
resolve();
}
});
},
......@@ -159,19 +181,45 @@ Page({
productDetailVisible: true
})
},
/**
* 点击扫码按钮
*/
onScanHandler() {
let _this = this;
wx.scanCode({
onlyFromCamera: true,
success(res) {
// 扫码结果
let result = res.result;
let {
qrCodeCode,
memberCode
} = result;
let q = res.result;
console.log("q:", q)
// 获取会员码
let m = getQueryByUrl("m", q);
console.log("m:", m)
if (m) {
_this.setData({
memberCode: m
})
_this.queryScanPersonQrcode();
}
// 获取积分码
let c = getQueryByUrl("c", q);
if (c) {
app.router.push({
path: "scanResult",
query: {
code: c
}
})
} else {
wx.showModal({
content: '未发现积分码,换一个二维码试试',
showCancel: false,
success(res) {}
})
}
},
fail(err) {
console.log("err:", err);
......@@ -183,10 +231,22 @@ Page({
* 点击搜索
*/
onSearchHandler() {
let code = this.data.code;
this.setData({
code: ""
})
if (code.length != 16) {
wx.showModal({
content: '请输入16位积分码',
showCancel: false,
success(res) {}
})
return;
}
app.router.push({
path: "scanResult",
query: {
code: this.data.code
code: code
}
})
},
......
......@@ -14,10 +14,10 @@
<image class="icon" mode="aspectFit" src="../../image/icon/icon-search.png" />
</view>
<!-- 隐藏扫描二维码 -->
<!-- <view class="search-line"></view>
<view class="search-line"></view>
<view bindtap="onScanHandler" class="search-scan">
<image class="icon" mode="aspectFit" src="../../image/icon/icon-scan.png" />
</view> -->
</view>
</view>
</view>
<view class="top-space"></view>
......
......@@ -21,6 +21,9 @@ Page({
initData() {
// 获取用户信息 小程序码
this.queryMember().then((result) => {
wx.showLoading({
title: '二维码生成中···',
});
// 获取海报数据
let posterData = this.getPosterConfig();
// 绘制设置海报
......
import {
getBindtapData,
getQueryByUrl
} from '../../utils/util';
let app = getApp();
Page({
data: {
......@@ -14,21 +19,11 @@ Page({
},
onLoad(options) {
// 扫小程序码进入
let scene = decodeURIComponent(options.scene) || "";
// scene = "02llmPvYl1CFN2bc"
if (scene) {
this.setData({
scene
})
}
// 手输码
let code = options.code || "";
console.log("code:", code);
if (code) {
this.setData({
scene: code
code: code
})
}
......@@ -65,13 +60,13 @@ Page({
queryScanIntegralQrcode() {
return new Promise((resolve, reject) => {
let {
scene
code
} = this.data;
if (scene) {
if (code) {
app.post({
url: app.api.scanIntegralQrcode,
data: {
qrCodeCode: scene
qrCodeCode: code
}
}).then((result) => {
this.setData({
......@@ -101,6 +96,42 @@ Page({
});
},
/**
* 点击扫码按钮
*/
onScanHandler() {
let _this = this;
wx.scanCode({
onlyFromCamera: true,
success(res) {
// 扫码结果
let q = res.result;
// 获取积分码
let c = getQueryByUrl("c", q);
if (c) {
// app.router.push({
// path: "scanResult",
// query: {
// code: c
// }
// })
_this.queryScanIntegralQrcode();
} else {
wx.showModal({
content: '未发现积分码,换一个二维码试试',
showCancel: false,
success(res) {}
})
}
},
fail(err) {
console.log("err:", err);
}
})
},
/**
* 查看我的积分
*/
......
......@@ -13,7 +13,7 @@
积分
</view>
<view class="btn-wrap">
<!-- <view class="btn">再扫一次</view> -->
<view bindtap="onScanHandler" class="btn">再扫一次</view>
<view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view>
</view>
</view>
......@@ -25,7 +25,7 @@
<!-- 其他异常 -->
<text wx:else class="tips tips1">此产品码已被扫过!\n若有异常,请联系客服</text>
<view class="btn-wrap">
<!-- <view class="btn">再扫一次</view> -->
<view bindtap="onScanHandler" class="btn">再扫一次</view>
<view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view>
<!-- <view class="btn btn2">联系客服</view> -->
</view>
......
......@@ -90,11 +90,11 @@ Page({
toast: false,
url: app.api.sign,
}).then((result) => {
this.queryMember().then((result) => {
this.querySignInfo().then((result2) => {
this.queryMember().then((result2) => {
this.querySignInfo().then((result3) => {
// 签到成功
this.setData({
signPrize: result2,
signPrize: result,
giftSignTipsCompVisible: true
})
})
......
......@@ -122,6 +122,16 @@ function formatWeek(week) {
return result;
}
/**
* 根据url获取参数
* @param {*} name
*/
function getQueryByUrl(name, url) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ""])[1].replace(/\+/g, '%20')) || null;
}
/**
* 获取点击传值
* @param {*} evt
......@@ -232,5 +242,6 @@ module.exports = {
formatWeek: formatWeek,
getBindtapData: getBindtapData,
wxacodeGet: wxacodeGet,
getObjByListKeyValue: getObjByListKeyValue
getObjByListKeyValue: getObjByListKeyValue,
getQueryByUrl: getQueryByUrl,
}
......