ada19efb by simon

版本提交

1 parent 1283d91e
......@@ -24,10 +24,14 @@ App({
wxcode: store.getItem("wxcode"),
tlMemberCode: "",
curCoupon: null,
questionResult:null,//答题的结果 弹力值 elasticValue
questionResult: null, //答题的结果 弹力值 elasticValue
posterWishList: [], //海报用
giftData: null, // 实物奖 userTabel prizeDetail用
},
// 获取用户基本信息
queryIndex() {
queryIndex(query = {
auth: true
}) {
return new Promise((resolve, reject) => {
this.post({
url: this.api.index,
......@@ -36,7 +40,7 @@ App({
}).then((result) => {
this.globalData.indexInfo = result;
this.globalData.userInfo = result.userInfo;
if (result.isNeedAuth == 1) {
if (result.isNeedAuth == 1 && auth == true) {
//需要授权
this.router.push({
path: "authorize"
......
......@@ -34,18 +34,22 @@ Component({
provinceList: [],
cityList: [],
districtList: [],
provinceIndex: -1,
cityIndex: -1,
districtIndex: -1,
provinceIndex: 0,
cityIndex: 0,
districtIndex: 0,
addressList: [],
total: 0,
curAddress: null
curAddress: null,
localCity: ""
},
methods: {
/**
* 请求门店地址
*/
queryShop() {
this.setData({
curAddress: ""
})
return new Promise((resolve, reject) => {
let {
location,
......@@ -69,7 +73,8 @@ Component({
}).then((result) => {
this.setData({
addressList: result.list,
total: result.total
total: result.total,
localCity: result.city
})
resolve();
})
......@@ -95,6 +100,7 @@ Component({
/**
* 提交门店
* 预约
*/
onSubmitHandler(evt) {
let curAddress = this.data.curAddress;
......@@ -147,6 +153,7 @@ Component({
this.setData({
searchMode: 2
});
this.queryShop();
},
// 转换为自动模式
......@@ -157,6 +164,7 @@ Component({
cityId: "",
districtId: "",
})
this.queryShop();
},
getProvince() {
......@@ -180,7 +188,9 @@ Component({
parentId: this.data.provinceId
}
}).then((result) => {
console.log("getCity result:", result);
this.setData({
cityList: result
})
})
});
},
......@@ -193,7 +203,9 @@ Component({
parentId: this.data.cityId
}
}).then((result) => {
console.log("getDistrict result:", result);
this.setData({
districtList: result
})
})
});
},
......@@ -204,10 +216,11 @@ Component({
provinceIndex: index,
provinceId: this.data.provinceList[index].id,
cityList: [],
cityIndex: -1,
districtList: [],
districtIndex: -1,
})
// 选市
this.getCity()
this.getCity();
},
bindPickerChangeCity(e) {
......@@ -216,6 +229,7 @@ Component({
cityIndex: index,
cityId: this.data.cityList[index].id,
districtList: [],
districtIndex: -1,
})
this.getDistrict();
},
......@@ -226,6 +240,7 @@ Component({
districtIndex: index,
districtId: this.data.districtList[index].id,
})
this.queryShop();
},
......
......@@ -4,7 +4,7 @@
<view wx:if="{{searchMode == 1}}" class="nav nav1">
<view class="place">
您当前所在城市:
<span class="city">深圳市</span>
<span class="city">{{localCity}}</span>
</view>
<view bindtap="onSearchHandModeHandler" data-data="1" class="btn">手动选择</view>
</view>
......
......@@ -361,7 +361,5 @@ let prizeTableQueryAssign = {
module.exports = {
productMap: productMap,
prizeTableQueryAssign: prizeTableQueryAssign,
prizeLiftQuery: prizeLiftQuery,
wishbillGiftQuery: wishbillGiftQuery
}
......
......@@ -11,9 +11,20 @@ function checkSessionId() {
resolve();
} else {
// 没有sessionId则获取并埋值
login().then((result) => {
resolve();
}).catch((err) => {
reject();
});
}
});
}
// 重新登陆
function login() {
return new Promise((resolve, reject) => {
wx.login({
success: function (res) {
console.log("wxlogin:", res);
Store.setItem('wxcode', res.code);
let baseUrl = config.NET_CONFIG.baseApi;
wx.request({
......@@ -21,8 +32,7 @@ function checkSessionId() {
data: {
code: res.code
},
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
// header: {}, // 设置请求的 header
method: 'POST',
success: function (res2) {
let {
code,
......@@ -38,13 +48,10 @@ function checkSessionId() {
});
reject();
}
// console.log("sid:", Store.getItem('sessionId'));
// resolve();
}
})
}
});
}
});
}
......@@ -59,14 +66,7 @@ const fetch = function ({
data,
method
}) {
// 自定义参数
// const clientInfo = {
// user_id: 1
// }
// 日志埋点不需要出现loading
if (loading && mode != 'log') wx.showLoading();
// if (loading && mode != 'log') Util.showLoading();
// 新建promise对象
let promise = new Promise((resolve, reject) => {
/**
......@@ -77,63 +77,66 @@ const fetch = function ({
if (isMock && mode != 'log') {
baseUrl = config.MOCKAPI; //环境配置
}
checkSessionId().then((result) => {
// if (sid) {
// url += "?sessionId=" + Store.getItem("sessionId")
// }
// url += "?sessionId=" + Store.getItem("sessionId")
// console.log("url:", url);
wx.request({
url: baseUrl + url, //请求地址
data: data, //自定义参数
method: method || 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header: {
sessionId: Store.getItem("sessionId")
}, // 设置请求的 header的默认参数,根据项目需求添加
// header: {
// 'clientInfo': JSON.stringify(clientInfo),
// 'Server-Token':'xxx'
// },
},
success: function (result) {
// 日志上传不需要处理结果
if (mode == 'log') return;
let res = result.data;
// 登陆失效拦截,根据项目需要添加自己的配置
if (res.code == 404) {
// wx.showToast({
// title: '当前登陆失效,请重新登陆',
// icon: 'none',
// mask: true,
// success: () => {
// return;
// }
// })
//登陆失效的回调
Store.clear("sessionId");
wx.reLaunch({
url: '/pages/authorize/authorize'
// wx.reLaunch({
// url: '/pages/index/index'
// })
// 404后拉取登陆后再做一次
login().then((resultLogin) => {
wx.request({
url: baseUrl + url, //请求地址
data: data, //自定义参数
method: method || 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
header: {
sessionId: Store.getItem("sessionId")
},
success: function (result) {
// 日志上传不需要处理结果
if (mode == 'log') return;
let res = result.data;
if (res.code === 200) {
if (loading) {
wx.hideLoading();
}
resolve(res.content);
} else {
// 有些特殊状况不需要toast 需要弹窗
if (toast) {
wx.showToast({
title: res.errMsg || errMsg,
icon: 'none'
})
} else {
wx.hideLoading();
}
// 返回错误信息
reject(res);
}
}
});
})
return;
// Router.push({
// path: "authorize",
// openType: "reLaunch",
// query: {
// status: '404'
// }
// })
}
// 内部统一的成功code拦截码
if (res.code === 200) {
if (loading) {
wx.hideLoading();
}
// resolve(res);
// 直接返回content
// 再多封一层,把errMsg塞带content去
// let content = res.content;
// content.errMsg = res.errMsg;
resolve(res.content);
} else {
// 有些特殊状况不需要toast 需要弹窗
......
......@@ -4,14 +4,24 @@ let config = require('../../config');
Page({
data: {
authorized: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
canIUse: wx.canIUse('button.open-type.getUserInfo'),
redirect: "index",
},
onShareAppMessage() {},
onReady() {
wx.showLoading();
this.autoAuth();
},
onLoad(options) {},
onLoad(options) {
let {
redirect
} = options;
if (redirect) {
this.setData({
redirect
})
}
},
onShow() {},
bindGetUserInfo(e) {
wx.showLoading();
......@@ -52,7 +62,7 @@ Page({
let _this = this;
this.refreshIndexData().then((result) => {
if (result.isNeedAuth == 1) {
console.log("result.isNeedAuth:",result.isNeedAuth);
console.log("result.isNeedAuth:", result.isNeedAuth);
// 未授权
wx.login({
success: function (res) {
......@@ -64,7 +74,7 @@ Page({
authorized: false
})
} else {
console.log("result.isNeedAuth:",result.isNeedAuth);
console.log("result.isNeedAuth:", result.isNeedAuth);
// 已经授权
// setTimeout(() => {
_this.toIndex();
......@@ -75,9 +85,8 @@ Page({
},
// 跳转到首页
toIndex() {
console.log("toIndex");
app.router.push({
path: "index",
path: this.data.redirect,
openType: "redirect"
})
wx.hideLoading();
......
......@@ -10,23 +10,53 @@ import {
let app = getApp();
Page({
data: {
groupMemberCoopVisible: true,
groupMemberCoopVisible: false,
tipsCommonVisible: false,
tipsInnerText: "",
options: null,
wishInfo: {},
wishList: []
wishList: [],
coopInfo: {},
canShake: false,
},
onShareAppMessage() {},
onLoad(options) {
this.setData({
options
})
},
onShow() {
this.initData();
},
initData() {
app.queryIndex().then((result) => {
// 判断是否需要授权
if (result.isNeedAuth) {
app.router.push({
path: "authorize",
query: {
redirect: "coop"
}
})
} else {
this.queryWishbillDetail();
this.initShake();
}
})
},
// 添加摇一摇
initShake() {
let _this = this;
wx.onAccelerometerChange(function (res) {
if (!_this.data.canShake) {
return
}
if (res.x > 1) { //偏移量为2时触发,有的使用1
// 触发摇一摇
_this.queryWishbillAssist();
}
});
},
// 我也要玩
onPlayTooHandler() {
app.router.push({
......@@ -34,15 +64,70 @@ Page({
path: "index"
})
},
// 助力
queryWishbillAssist() {
this.setData({
canShake: false
})
app.post({
url: app.api.wishbillAssist,
data: {
billCode: this.data.options.code
}
}).then((result) => {
console.log("queryWishbillAssist result:", result);
let status = result.status;
if (status == 1) {
// 助力成功
// 合并数据
let wishList = result.elasticValueList;
wishList.forEach(element => {
let product = productMap[element.prizeDefineCode + ""];
element = Object.assign(element, product);
let progress = element.elasticValue / element.conditionElasticValue * 100;
if (progress > 100) progress = 100;
// 直接计算坐标
let progressLeft = progress * 3.22 - 51;
element.progress = progress;
element.progressLeft = progressLeft;
});
this.setData({
coopInfo: result,
wishList: wishList
})
} else if (status == 2) {
// 助力失败
this.setData({
tipsCommonVisible: true,
tipsInnerText: "已经为好友助力过啦~"
})
} else if (status == 3) {
this.setData({
tipsCommonVisible: true,
tipsInnerText: "不能为自己助力哦~"
})
} else {
// 助力失败
this.setData({
groupMemberCoopVisible: true
})
}
})
},
// 获取心愿单详情
queryWishbillDetail() {
return new Promise((resolve, reject) => {
app.post({
url: app.api.wishbillDetail,
data: {
billCode: app.globalData.indexInfo.wishBillCode
billCode: this.data.options.code
}
}).then((result) => {
let isAssist = result.isAssist;
this.setData({
isAssist
})
let wishList = result.wishGifts;
wishList.forEach(element => {
let product = productMap[element.prizeDefineCode + ""];
......@@ -60,9 +145,16 @@ Page({
})
console.log("wishInfo:", this.data.wishInfo);
console.log("wishList:", this.data.wishList);
})
});
},
hideMask() {
this.setData({
groupMemberCoopVisible: false,
tipsCommonVisible: false,
})
},
// 子组件事件
evtcomp(evt) {
let {
......@@ -71,7 +163,8 @@ Page({
} = evt.detail;
switch (name) {
case "_evt_hide":
case "_evt_hide_mask":
this.hideMask();
break;
default:
......
......@@ -2,6 +2,7 @@
"navigationBarTitleText": "好友助力",
"usingComponents": {
"tips-group-member-coop-comp": "../../component/tips-group-member-coop-comp/tips-group-member-coop-comp",
"tips-common-comp": "../../component/tips-common-comp/tips-common-comp",
"van-popup": "../../ui/vant-weapp/popup/index"
}
}
......
......@@ -131,10 +131,7 @@
.result-wrap {
position: relative;
.play-too-btn {
@include cb(234px, 64px);
margin: 12px auto 0;
}
}
// 摇后结果
......@@ -295,6 +292,11 @@
}
}
.play-too-btn {
@include cb(234px, 64px);
margin: 24px auto 0;
}
}
}
}
......
......@@ -8,7 +8,8 @@
<view class="top-space"></view>
<view class="content">
<!-- 摇一摇 -->
<view wx:if="{{1>10}}" class="shake">
<!-- bindtap="queryWishbillAssist" -->
<view wx:if="{{coopInfo.isAssist != 1}}" class="shake">
<image class="ebg" mode="widthFix" src="../../image/oss/coop/coop-c2.png" />
<view class="space1"></view>
<view class="cont">
......@@ -22,6 +23,7 @@
</view>
</view>
</view>
<view bindtap="onPlayTooHandler" class="play-too-btn">我也要玩</view>
</view>
<!-- 摇后结果 -->
<view wx:else class="result-wrap">
......@@ -36,7 +38,7 @@
</view>
</view>
<view class="tips2">
<text class="t1">太厉害了\n您总共摇出了140弹力值</text>
<text class="t1">太厉害了\n您总共摇出了{{coopInfo.totalElasticValue}}弹力值</text>
</view>
<!-- 奖品 -->
<view class="wish">
......@@ -71,3 +73,7 @@
<van-popup show="{{ groupMemberCoopVisible }}">
<tips-group-member-coop-comp bind:evtcomp="evtcomp"></tips-group-member-coop-comp>
</van-popup>
<van-popup show="{{ tipsCommonVisible }}">
<tips-common-comp bind:evtcomp="evtcomp" inner-text="{{tipsInnerText}}"></tips-common-comp>
</van-popup>
......
import {
getBindtapData
wishbillGiftQuery
} from '../../const/custom-data';
import {
getBindtapData,
pxToRpx
} from '../../utils/util';
import Date from '../../utils/date';
import QR from '../../utils/qrcode'
let app = getApp();
Page({
data: {
nearbyStoreVisible: true,
userInfo: {},
used: false, //优惠券已使用,另外的样式
couponInfo: {
"couponId": "20839",
"couponCode": "RLLL1IHG",
"rule": "RLLL1IHG",
"startDate": 1564479217000,
"endDate": 1567094399000,
"type": 4,
"name": "眼部护理体验券-7月24日",
"state": 0,
"endDateStr": "19-08-29"
}
wishInfo: {},
couponInfo: {},
nearbyStoreVisible: false,
qrImagePath: "",
location: {},
},
onShareAppMessage() {},
onLoad(options) {
app.queryIndex().then((result) => {
let couponInfo = this.data.couponInfo;
// let wishInfo = options;
let wishInfo = wishbillGiftQuery.order;
let couponInfo = wishInfo.coupon;
// 设置起止时间
couponInfo.startDateStr = new Date(couponInfo.startDate).toString("yyyy.MM.dd");
couponInfo.endDateStr = new Date(couponInfo.endDate).toString("yyyy.MM.dd");
// 判断是否使用
// 自提券 使用状态(0=未使用 1=已过期,2=已使用)
let used = couponInfo.state != 0;
// used = true;
// 设置数据
this.setData({
userInfo: app.globalData.userInfo,
couponInfo: couponInfo
wishInfo: wishInfo,
couponInfo: couponInfo,
used: used
})
this.initData();
})
},
initData() {
// this.setData({
// couponInfo: app.globalData.curCoupon
// })
app.queryIndex().then((result) => {
this.setData({
userInfo: app.globalData.userInfo
})
// 设置二维码
let couponInfo = this.data.couponInfo;
let qrSize = this.setCanvasSize(340);
console.log("couponInfo:", couponInfo);
let codeContent = couponInfo.couponCode || '';
this.createQrCode(codeContent, 'qrcanvas', qrSize.w, qrSize.h);
})
},
/**
* 请求门店地址
*/
queryShop() {
this.selectComponent("#nearbyStoreComp").queryShop().then((result) => {
this.setData({
nearbyStoreVisible: true
})
})
},
// 查看可用门店
onNearbyStoreHandler() {
onNearbyStoreHandler(evt) {
this.wxLocation();
},
// 使用微信位置
wxLocation() {
let _this = this;
wx.getLocation({
type: 'wgs84',
success(res) {
_this.setData({
location: res
})
_this.queryShop();
},
fail(err) {
wx.getSetting({
success: (res) => {
if (!res.authSetting['scope.userLocation']) {
// 未授权
wx.showModal({
title: '提示',
content: '小程序请求访问地理位置',
confirmText: '前往授权',
success(res) {
if (res.confirm) {
wx.openSetting({
complete() {
//设置完后重拉一遍位置,拉不到就算了
wx.getLocation({
type: 'wgs84', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
success: function (res) {
_this.setData({
location: res
})
_this.queryShop();
},
fail: function () {
_this.queryShop();
}
})
}
})
} else if (res.cancel) {
// 模态窗取消
_this.queryShop();
}
}
})
}
}
})
}
})
},
createQrCode(content, canvasId, cavW, cavH) {
//调用插件中的draw方法,绘制二维码图片
QR.api.draw(content, canvasId, cavW, cavH);
this.canvasToTempImage(canvasId);
},
//获取临时缓存图片路径,存入data中
canvasToTempImage(canvasId) {
let that = this;
wx.canvasToTempFilePath({
canvasId, // 这里canvasId即之前创建的canvas-id
success: function (res) {
let tempFilePath = res.tempFilePath;
console.log(tempFilePath);
that.setData({ // 如果采用mpvue,即 this.imagePath = tempFilePath
qrImagePath: tempFilePath,
});
},
fail: function (res) {
console.log(res);
}
});
},
//适配不同屏幕大小的canvas
setCanvasSize(sz) {
var size = {};
try {
var res = wx.getSystemInfoSync();
var scale = 750 / sz; //不同屏幕下canvas的适配比例;设计稿是750宽
var width = res.windowWidth / scale;
var height = width; //canvas画布为正方形
size.w = width;
size.h = height;
} catch (e) {
// Do something when catch error
console.log("获取设备信息失败" + e);
}
return size;
},
hideMask() {
this.setData({
nearbyStoreVisible: false
......@@ -56,6 +175,18 @@ Page({
switch (name) {
case "_evt_hide":
this.hideMask();
break;
// 提交完毕
case "_evt_submit_store_complete":
// 刷新状态
this.hideMask();
wx.showModal({
content: '预约成功',
showCancel: false,
success(res) {}
});
break;
default:
......
......@@ -82,8 +82,17 @@
.qrcode {
width: 340px;
height: 340px;
background-color: wheat;
margin: 0 auto;
image {
width: 340px;
height: 340px;
}
canvas {
width: 340px;
height: 340px;
}
}
.code {
......@@ -110,14 +119,20 @@
// 已使用
.used {
$alp: 0.3;
.qrcode {
opacity: $alp;
}
.info {
opacity: $alp;
}
// .qrcode {
// opacity: $alp;
// }
// .info {
// opacity: $alp;
// }
// .code{
// opacity: $alp;
// }
}
......
......@@ -4,7 +4,7 @@
<view class="decoration">
<image class="d1" src="../../image/oss/my-card/my-card-d1.png" mode="widthFix" />
<image class="d2" src="../../image/oss/my-card/my-card-d2.png" mode="widthFix" />
<image class="d3" src="../../image/oss/question/question-c1.png" mode="widthFix" />
<!-- <image class="d3" src="../../image/oss/question/question-c1.png" mode="widthFix" /> -->
</view>
<view class="app__content main">
<view class="top-space"></view>
......@@ -17,7 +17,10 @@
<view class="cont {{used?'used':''}}">
<view class="space1"></view>
<!-- 二维码 -->
<view class="qrcode"></view>
<view class="qrcode">
<image wx:if="{{qrImagePath}}" class="image" mode="widthFix" src="{{qrImagePath}}" />
<canvas wx:else canvas-id="qrcanvas" />
</view>
<view class="code">{{couponInfo.couponCode}}</view>
<view class="info">
<view class="c1">手机号:{{userInfo.mobile}}</view>
......@@ -36,5 +39,5 @@
</view>
</view>
<van-popup show="{{ nearbyStoreVisible }}" position="bottom" bind:click-overlay="hideMask">
<tips-nearby-store-comp bind:evtcomp="evtcomp" wish-info="{{curWish}}" status="{{status}}"></tips-nearby-store-comp>
<tips-nearby-store-comp id="nearbyStoreComp" bind:evtcomp="evtcomp" wish-info="{{wishInfo}}" location="{{location}}" selectedMode="{{false}}"></tips-nearby-store-comp>
</van-popup>
......
......@@ -62,19 +62,24 @@ Page({
initShake() {
let _this = this;
wx.onAccelerometerChange(function (res) {
if (this.data.isPageVisible && this.data.isPageVisible) {
if (res.x > 2) { //偏移量为2时触发,有的使用1
wx.showModal({
title: '提示',
content: '触发摇一摇',
success: res => {
if (!_this.data.isPageVisible || !_this.data.isPageVisible) {
return
}
if (res.x > 1) { //偏移量为2时触发,有的使用1
_this.setData({
tipsShakeVisible: false,
tipsCreateCompleteVisible: true
})
}
})
}
// wx.showModal({
// title: '提示',
// content: '触发摇一摇',
// success: res => {
// _this.setData({
// tipsShakeVisible: false,
// tipsCreateCompleteVisible: true
// })
// }
// })
}
});
},
......
......@@ -223,6 +223,11 @@
height: 64px;
line-height: 64px;
}
.disable {
background: transparent;
background-color: #d2d2d2;
}
}
.btn {
......
......@@ -27,10 +27,10 @@
<view class="content">
<!-- <view class="btn" bindtap="onWishHandler">提交心愿单</view> -->
<!-- 换一批按钮 -->
<view class="change-btn" bindtap="onChangeStatusHandler">
<!-- <view class="change-btn" bindtap="onChangeStatusHandler">
<image class="icon" src="../../image/oss/create-wish/cw-exchange-btn.png" mode="widthFix" />
换一批
</view>
</view> -->
<!-- 心愿单 -->
<view class="wish-container">
<image class="ebg" mode="widthFix" src="../../image/oss/create-wish/cw-border.png" />
......@@ -50,7 +50,9 @@
</view>
</view>
<!-- 提交心愿单 -->
<view bindtap="onSubmitHandler" class="btn submit-btn">提交心愿单</view>
<view bindtap="onSubmitHandler" class="btn submit-btn {{myWishList.length <= 0 ? 'disable' : ''}}">
提交心愿单
</view>
</view>
</view>
</view>
......
let app = getApp();
Page({
data: {
authorized: true,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
tipsRuleVisible: false,
indexInfo: {}
},
onShareAppMessage() {},
onLoad(options) {
this.initData();
},
initData() {
app.queryIndex().then((result) => {
console.log("result:", result);
app.queryIndex({
auth: false
}).then((result) => {
this.setData({
indexInfo: app.globalData.indexInfo
})
})
},
// 开始互动游戏
......@@ -51,4 +55,26 @@ Page({
break;
}
},
bindGetUserInfo(e) {
wx.showLoading();
this.getUserInfo(e.detail);
},
getUserInfo(e) {
let _this = this;
app.post({
url: app.api.register,
sid: false,
data: {
encryptedData: e.encryptedData,
iv: e.iv,
code: app.globalData.wxcode,
tlMemberCode: app.globalData.tlMemberCode
}
}).then((res2) => {
wx.hideLoading();
_this.onStartHandler();
}).catch((err) => {})
},
})
......
......@@ -13,7 +13,12 @@
<view class="top-space"></view>
<view class="content">
<!-- 已授权 直接到下一步操作 -->
<button class="btn" wx:if="{{authorized}}" bindtap="onStartHandler">马上测弹力值</button>
<!-- 需要授权 -->
<button wx:if="{{indexInfo.isNeedAuth == 1}}" bindgetuserinfo="bindGetUserInfo" class="btn">
马上测弹力值
</button>
<!-- 已授权 -->
<button wx:else bindtap="onStartHandler" class="btn">马上测弹力值</button>
<!-- 未授权 拉起授权弹窗 -->
<!-- <button class="btn" wx:else open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">马上测弹力值2</button> -->
</view>
......
......@@ -22,8 +22,9 @@
</view>
</view>
</view>
<view class="store-btn" bindtap="onNearbyStoreHandler">
<!-- 查看门店需要 couponId -->
<!-- <view class="store-btn" bindtap="onNearbyStoreHandler">
<span class="c1">附近门店查询</span>
</view>
</view> -->
</view>
</view>
......
......@@ -6,6 +6,7 @@ Page({
wxShareTitle: "", // 分享标题
wxCodePath: "", // 微信二维码参数地址,分享链接公用
wxCodeUrl: "", // 微信二维码图片地址
wishList: [],
},
onShareAppMessage() {
if (res.from === 'button') {
......@@ -25,6 +26,10 @@ Page({
}
},
onLoad(options) {
// this.setData({
// wishList: wishList
// })
app.queryIndex().then((result) => {
console.log("result:", result);
wx.showLoading({
......@@ -149,15 +154,13 @@ Page({
getPosterConfig() {
// 合成图片需要的数据
let {
userInfo
userInfo,
posterWishList,
} = app.globalData;
let codeUrl = this.data.wxCodeUrl;
let posterData = {
width: 700,
height: 921,
debug: false,
blocks: [],
images: [
console.log("posterWishList:", posterWishList);
let images = [
// 底图
{
width: 700,
......@@ -184,9 +187,9 @@ Page({
url: codeUrl,
zIndex: 14
}
],
lines: [],
texts: [{
];
let texts = [{
x: 165,
y: 810,
width: 360,
......@@ -197,7 +200,58 @@ Page({
text: `${userInfo.nickname}正在参加丸美眼霜节心愿单活动,需要你的倾情相助!`,
color: '#666666',
zIndex: 111
}],
}];
let originPoint = {
x: 55,
y: 160,
}
posterWishList.forEach((element, index) => {
// 产品背景
let egb = {
width: 165,
height: 165,
x: originPoint.x + (215 * index),
y: originPoint.y,
url: '../../image/draw/draw-c2.png',
}
// 产品图
let product = {
width: 165,
height: 165,
x: originPoint.x + (215 * index),
y: originPoint.y,
url: '../../image/prize/prize-' + element.tag + '.png',
}
let productDesc = {
x: originPoint.x + (215 * index),
y: originPoint.y + 165 + 12,
width: 165,
fontSize: 24,
lineHeight: 28,
lineNum: 3,
baseLine: 'top',
text: `${element.prizeName}`,
color: '#bc3239',
zIndex: 111
}
images.push(egb);
images.push(product);
texts.push(productDesc);
});
let posterData = {
width: 700,
height: 921,
debug: false,
blocks: [],
images: images,
lines: [],
texts: texts,
}
return posterData;
},
......
import {
wishbillGiftQuery
} from '../../const/custom-data';
import {
getBindtapData,
pxToRpx
pxToRpx,
getLocalDistance
} from '../../utils/util';
import Date from '../../utils/date';
import QR from '../../utils/qrcode'
let app = getApp();
Page({
data: {
......@@ -24,40 +20,67 @@ Page({
},
onShareAppMessage() {},
onLoad(options) {
// let wishInfo = options;
let wishInfo = wishbillGiftQuery.order;
let couponInfo = wishInfo.coupon;
// 设置起止时间
couponInfo.startDateStr = new Date(couponInfo.startDate).toString("yyyy.MM.dd");
couponInfo.endDateStr = new Date(couponInfo.endDate).toString("yyyy.MM.dd");
// 判断是否使用
// 自提券 使用状态(0=未使用 1=已过期,2=已使用)
let used = couponInfo.state != 0;
// used = true;
let giftData = app.globalData.giftData;
let wishInfo = giftData.order;
let couponInfo = wishInfo.coupon;
// 设置数据
this.setData({
wishInfo: wishInfo,
couponInfo: couponInfo,
used: used
couponInfo: couponInfo
})
this.initData();
},
initData() {
let _this = this;
app.queryIndex().then((result) => {
this.setData({
userInfo: app.globalData.userInfo
})
let wishInfo = this.data.wishInfo;
let couponInfo = wishInfo.coupon;
// 设置二维码
let couponInfo = this.data.couponInfo;
let qrSize = this.setCanvasSize(300);
console.log("couponInfo:", couponInfo);
let codeContent = couponInfo.couponCode || '';
this.createQrCode(codeContent, 'qrcanvas', qrSize.w, qrSize.h);
// 判断是否使用
// 自提券 使用状态(0=未使用 1=已过期,2=已使用)
let used = couponInfo.state != 0;
// 设置起止时间
couponInfo.startDateStr = new Date(couponInfo.startDate).toString("yyyy.MM.dd");
couponInfo.endDateStr = new Date(couponInfo.endDate).toString("yyyy.MM.dd");
// 设置数据
this.setData({
couponInfo: couponInfo,
used: used
})
// 设置坐标
wx.getLocation({
type: 'gcj02',
success(res) {
let targetLocation = {
latitude: wishInfo.latitude,
longitude: wishInfo.longitude,
}
let distance = getLocalDistance(res, targetLocation).dis;
wishInfo.distance = distance;
console.log("distance:", distance);
_this.setData({
wishInfo: wishInfo
})
}
})
})
},
/**
......@@ -78,7 +101,7 @@ Page({
wxLocation() {
let _this = this;
wx.getLocation({
type: 'wgs84',
type: 'gcj02',
success(res) {
_this.setData({
location: res
......@@ -125,6 +148,27 @@ Page({
}
})
},
/**
* 显示位置
* @param {*} e
*/
onShowLocHandler(evt) {
let item = this.data.wishInfo;
console.log("item:", item);
wx.openLocation({
latitude: item.latitude, // 纬度,范围为-90~90,负数表示南纬
longitude: item.longitude, // 经度,范围为-180~180,负数表示西经
scale: 18, // 缩放比例
name: item.storeName, // 位置名
address: item.storeAddress, // 地址的详细说明
success: function (res) {
// success
}
})
},
createQrCode(content, canvasId, cavW, cavH) {
//调用插件中的draw方法,绘制二维码图片
QR.api.draw(content, canvasId, cavW, cavH);
......@@ -185,11 +229,29 @@ Page({
case "_evt_submit_store_complete":
// 刷新状态
this.hideMask();
app.post({
url: app.api.wishbillGiftQuery,
data: {
instanceCode: curData.instanceCode
}
}).then((result) => {
// 重新拉取数据
let giftData = result;
let wishInfo = giftData.order;
let couponInfo = wishInfo.coupon;
this.setData({
wishInfo: wishInfo,
couponInfo: couponInfo
})
this.initData();
wx.showModal({
content: '预约成功',
showCancel: false,
success(res) {}
});
})
break;
default:
......
......@@ -89,6 +89,11 @@
width: 300px;
height: 300px;
}
canvas {
width: 300px;
height: 300px;
}
}
// 数字码
......@@ -134,7 +139,7 @@
.info {
@extend .bb;
padding: 0 40px 0 20px;
padding: 0 0px 0 0px;
.tit {
display: flex;
......@@ -142,7 +147,10 @@
font-size: 24px;
color: #333333;
.name {}
.name {
max-width: 250px;
@include ellipsis(1);
}
.distance {
margin-left: 16px;
......@@ -154,6 +162,7 @@
font-size: 20px;
color: #999999;
margin-top: 10px;
@include ellipsis(2);
}
}
......
<canvas style="width: 300rpx;height: 300rpx;visibility: hidden;position:absolute;" canvas-id="qrcanvas" />
<view class="page">
<view class="app__bgc bgc"></view>
<view class="app__bg bg"></view>
<view class="decoration">
<image class="d1" src="../../image/oss/my-card/my-card-d1.png" mode="widthFix" />
<image class="d2" src="../../image/oss/my-card/my-card-d2.png" mode="widthFix" />
<image class="d3" src="../../image/oss/question/question-c1.png" mode="widthFix" />
<!-- <image class="d3" src="../../image/oss/question/question-c1.png" mode="widthFix" /> -->
</view>
<view class="app__content main">
<view class="top-space"></view>
......@@ -28,11 +27,12 @@
</view>
<!-- 二维码 -->
<view class="qrcode">
<image class="image" mode="widthFix" src="{{qrImagePath}}" />
<image wx:if="{{qrImagePath}}" class="image" mode="widthFix" src="{{qrImagePath}}" />
<canvas wx:else canvas-id="qrcanvas" />
</view>
<view class="code">{{couponInfo.couponCode}}</view>
<!-- 预约自提按钮 -->
<view wx:if="{{1<10}}" bindtap="onNearbyStoreHandler" class="reservation-btn">
<view wx:if="{{!wishInfo.storeCode}}" bindtap="onNearbyStoreHandler" class="reservation-btn">
预约自提门店
</view>
<!-- 预约成功 -->
......@@ -42,12 +42,14 @@
<view class="pos">
<view class="info">
<view class="tit">
<view class="name">坂田天虹店</view>
<view class="distance">距您1.2公里</view>
<view class="name">{{wishInfo.storeName}}</view>
<view wx:if="{{wishInfo.distance}}" class="distance">
距您{{wishInfo.distance}}
</view>
<view class="address">地址:安徽省安庆市大观区集贤南路43号八佰伴购物中心一楼</view>
</view>
<view class="loc">
<view class="address">{{wishInfo.storeAddress}}</view>
</view>
<view bindtap="onShowLocHandler" data-data="{{item}}" class="loc">
<image class="icon" mode="widthFix" src="../../image/oss/icon/icon-loc.png" />
<view class="txt">导航</view>
</view>
......
......@@ -4,7 +4,7 @@ let Utils = require('../../utils/util.js');
let app = getApp();
Page({
data: {
tipsInnerText:"",
tipsInnerText: "",
redirect: "createWish", // 注册完的重定向页面
tipsRegisteredVisible: false,
tipsCommonVisible: false,
......@@ -13,8 +13,17 @@ Page({
mobile: "",
verifyCode: "",
birthday: "",
password: "qq123456",
sex: 1,
password: "",
sex: -1,
sexList: [{
label: "女",
value: 0
},
{
label: "男",
value: 1
},
],
isTerms: false,
// form end
auth_time: 0,
......@@ -25,8 +34,7 @@ Page({
onLoad(options) {
this.initData();
},
initData() {
},
initData() {},
showLog(msg) {
wx.showToast({
title: msg,
......@@ -74,18 +82,27 @@ Page({
// 表单检查
checkForm() {
return new Promise((resolve, reject) => {
if (!this.data.name) {
this.showLog("请输入姓名");
reject();
} else if (!this.data.mobile) {
if (!this.data.mobile) {
this.showLog("请输入手机号码");
reject();
} else if (!Utils.checkMobile(this.data.mobile)) {
this.showLog("请输正确手机号码");
reject();
} else if (!this.data.name) {
this.showLog("请输入姓名");
reject();
} else if (!this.data.birthday) {
this.showLog("请输入生日");
reject();
} else if (!this.data.password) {
this.showLog("请输入登陆密码");
reject();
} else if (!this.data.verifyCode) {
this.showLog("请输入验证码");
reject();
} else if (this.data.sex != 0 && this.data.sex != 1) {
this.showLog("请选择性别");
reject();
} else if (!this.data.isTerms) {
this.showLog("请同意服务条款");
reject();
......@@ -117,7 +134,7 @@ Page({
app.post({
url: app.api.mobileVerifyCode,
data: {
picVerifyCode:"",
picVerifyCode: "",
mobile: mobile,
forRegister: 1
}
......@@ -155,17 +172,22 @@ Page({
},
bindNameInput(e) {
this.setData({
"name": e.detail.value
name: e.detail.value
})
},
bindBirthdayInput(e) {
this.setData({
"birthday": e.detail.value
birthday: e.detail.value
})
},
bindPasswordInput(e) {
this.setData({
password: e.detail.value
})
},
bindVerifyCodeInput(e) {
this.setData({
"verifyCode": e.detail.value
verifyCode: e.detail.value
})
},
bindBirthdayChange(e) {
......@@ -173,6 +195,13 @@ Page({
birthday: e.detail.value
})
},
onSexRadioChange(e) {
this.setData({
sex: e.detail.value
})
console.log("sex:", this.data.sex);
},
// 子组件事件
evtcomp(evt) {
let {
......
{
"navigationBarTitleText": "登陆",
"navigationBarTitleText": "注册",
"usingComponents": {
"tips-register-ed-comp": "../../component/tips-register-ed-comp/tips-register-ed-comp",
"tips-common-comp": "../../component/tips-common-comp/tips-common-comp",
......
......@@ -73,10 +73,24 @@ $formWidth:560px;
}
}
}
.radio-group {
font-size: 28px;
color: #ba3138;
color: #db9a9d;
radio .wx-radio-input {
/* 自定义样式.... */
height: 32px;
width: 32px;
}
}
}
// 拼图
.puzzle {
margin-top: 32px;
$borderRadius: 32px;
width: $formWidth;
border-radius: $borderRadius;
......
......@@ -34,6 +34,13 @@
<input value="{{birthday}}" disabled="{{true}}" class="ipt-input" placeholder="生日" placeholder-class="placeholder" />
</view>
</picker>
<!-- 登陆密码 -->
<view class="ipt">
<view class="ipt-icon">
<image class="icon" mode="widthFix" src="../../image/oss/register/reg-icon-verify.png" />
</view>
<input password="{{true}}" value="{{password}}" bindinput="bindPasswordInput" class="ipt-input" placeholder="登陆密码" placeholder-class="placeholder" />
</view>
<!-- 验证码 -->
<view class="ipt">
<view class="ipt-icon">
......@@ -44,14 +51,21 @@
{{sendAuthCode ? "获取验证码": auth_time+"(s)"}}
</view>
</view>
<!-- 性别 -->
<radio-group class="radio-group" bindchange="onSexRadioChange">
<label class="radio" wx:for="{{sexList}}" wx:key="{{index}}">
<radio color="#ba3138" value="{{item.value}}" checked="{{item.checked}}" />
{{item.label}}
</label>
</radio-group>
</view>
<!-- 滑动拼图 -->
<view class="puzzle">
<!-- <view class="puzzle">
<view class="plz">
<image src="../../image/oss/register/plz-cont.png" mode="widthFix" />
</view>
<view class="slider"></view>
</view>
</view> -->
<!-- 条款/政策 -->
<view class="policy">
<span bindtap="onTermsHandler" class="check">
......
import {
prizeTableQueryAssign
} from '../../const/custom-data';
import {
getBindtapData,
......@@ -18,38 +15,58 @@ Page({
region: [],
regionStr: "",
prize: {},
wishInfo: {}
wishInfo: {},
order: {},
},
onShareAppMessage() {},
onLoad(options) {
// let wishInfo = options;
let wishInfo = prizeTableQueryAssign;
console.log("wishInfo:", wishInfo);
let wishInfo = app.globalData.giftData;
let order = wishInfo.order;
console.log("user-table wishInfo:", wishInfo);
console.log("user-table order:", order);
this.setData({
wishInfo: wishInfo
wishInfo: wishInfo,
order: order
})
if (wishInfo.associateMobile) {
if (order.associateMobile) {
// 如果初始化回显,则要设置 表单信息
// 显示省市区
this.setData({
receiverName: wishInfo.associateName,
receiverMobile: wishInfo.associateMobile,
receiverAddress: wishInfo.address,
regionStr: wishInfo.province + wishInfo.city + wishInfo.district,
receiverName: order.associateName,
receiverMobile: order.associateMobile,
receiverAddress: order.address,
regionStr: order.province + order.city + order.district,
})
this.setStatus(1);
} else {
this.setStatus(0);
}
},
/**
* 提交表单
* 提交表单按钮
* @param {*} evt
*/
onSubmitHandler(evt) {
let _this = this;
this.checkTable().then((result) => {
wx.showModal({
content: '提交确认?',
success(res) {
if (res.confirm) {
_this.doSubmit();
} else if (res.cancel) {}
}
})
})
},
// 检查表单
checkTable() {
return new Promise((resolve, reject) => {
let wishInfo = this.data.wishInfo;
let order = wishInfo.order;
let {
receiverName,
receiverMobile,
......@@ -64,28 +81,53 @@ Page({
if (!receiverName) {
tips = "请输入姓名";
this.showTips(tips);
reject();
return;
}
if (!receiverMobile) {
tips = "请输入手机号码";
this.showTips(tips);
reject();
return;
}
if (!checkMobile(receiverMobile)) {
tips = "请输入正确的手机号";
this.showTips(tips);
reject();
return;
}
if (!receiverProvince || !receiverCity || !receiverDistrict) {
tips = "请选择区域";
this.showTips(tips);
reject();
return;
}
if (!receiverAddress) {
tips = "请填写地址";
this.showTips(tips);
reject();
return;
}
resolve();
});
},
/**
* 提交表单
* @param {*} evt
*/
doSubmit() {
let wishInfo = this.data.wishInfo;
let order = wishInfo.order;
let {
receiverName,
receiverMobile,
receiverAddress,
region,
} = this.data;
let receiverProvince = region[0];
let receiverCity = region[1];
let receiverDistrict = region[2];
let data = {
......@@ -97,14 +139,26 @@ Page({
district: receiverDistrict,
address: receiverAddress,
}
console.log("data:", data);
// 提交完毕
app.post({
url: app.api.wishbillAddressSubmit,
data: data
}).then((result) => {
app.post({
url: app.api.wishbillGiftQuery,
data: {
instanceCode: order.instanceCode
}
}).then((result) => {
order = result.order
this.setData({
order: order
})
this.setStatus(1);
})
})
},
// 设置显示状态 0:填写 1:回显
......@@ -116,16 +170,15 @@ Page({
this.setData({
tableIndex: tableIndex
})
console.log("tableIndex:", tableIndex);
},
/**
* 配置完整地址
*/
refreshFullAddress() {
let {
receiverAddress,
regionStr,
} = this.data;
let addressStr = regionStr + receiverAddress;
let order = this.data.order;
let addressStr = `${order.province}${order.city}${order.district}${order.address}`;
console.log("addressStr:", addressStr);
this.setData({
addressStr: addressStr
})
......
......@@ -71,16 +71,16 @@
<view class="tips">*感谢您提交的地址,我们将尽快为您送出以上礼品</view>
<view class="form">
<view class="form-item">
<view class="label">{{wishInfo.associateName}}</view>
<view class="val">林小美</view>
<view class="label">姓名</view>
<view class="val">{{order.associateName}}</view>
</view>
<view class="form-item">
<view class="label">电话</view>
<view class="val">{{wishInfo.associateMobile}}</view>
<view class="val">{{order.associateMobile}}</view>
</view>
<view class="form-item">
<view class="label">地址</view>
<view class="val">{{regionStr}}{{wishInfo.addressStr}}</view>
<view class="val">{{addressStr}}</view>
</view>
</view>
<view bindtap="onWishHandler" class="submit-btn">返回首页</view>
......
......@@ -10,28 +10,30 @@ import {
let app = getApp();
Page({
data: {
isOverShare: true, //自定义分享
tipsRuleVisible: false,
tipsPirzeVisible: false,
userInfo: {},
wishInfo: {},
wishList: [],
helperInfo: {},
// curWish: {},
curWish: {
"status": 1,
"order": {
"acceptType": 0,
"instanceCode": "162951b667a746188c83491bd5601164",
"prizeName": "丸美弹力蛋白眼精华素10g+10g",
"prizePic": "",
"commodityNo": "11059001"
},
"coupon": null
},
curWish: {},
status: 1, // 1正常(有库存) 2无库存
},
onShareAppMessage() {},
onLoad(options) {
onShareAppMessage(res) {
if (res.from === 'button') {
// 来自页面内转发按钮
console.log(res.target)
}
let userInfo = app.globalData.userInfo;
let title = `${userInfo.nickname}正在参加丸美眼霜节心愿单活动,需要你的倾情相助!`;
return {
title,
}
},
onLoad(options) {},
onShow() {
this.initData();
},
initData() {
......@@ -77,15 +79,16 @@ Page({
}
}).then((result) => {
curData = Object.assign(curData, result);
console.log("curData 222:", curData);
this.setData({
curWish: curData,
status: curData.status
})
app.globalData.giftData = curData;
// 领取状态
// 领取类型:0=未提交;1=邮寄(填写邮寄信息);2=自提(填门店预约信息)
let acceptType = curData.order.acceptType;
console.log("acceptType:",acceptType);
console.log("acceptType:", acceptType);
if (acceptType == 0) {
// 未提交,显示领取选择
this.setData({
......@@ -122,6 +125,7 @@ Page({
},
// 显示海报图
onCreatePosterHandler() {
app.globalData.posterWishList = this.data.wishList;
app.router.push({
path: "poster"
})
......
......@@ -76,7 +76,7 @@
</view>
<view class="btn-wrap">
<view bindtap="onRankHandler" class="btn btn2">弹力girl榜单</view>
<view bindtap="onShareHandler" class="btn">弹弹好友</view>
<button open-type="share" class="btn">弹弹好友</button>
</view>
</view>
<!-- 规则按钮 -->
......
......@@ -54,6 +54,7 @@ function push(path, option = {}) {
query = {}, openType = 'navigate', duration = 0
} = option;
// json 转换为 字符串拼接参数
console.log("query:", query);
let params = parse(query)
// console.log("params:", params);
if (params) {
......
......@@ -149,6 +149,43 @@ function getObjByListKeyValue(value, key, list) {
return result;
}
function rad(d) {
return d * Math.PI / 180.0;
}
/**
* 获取微信距离
* @param {*} locationRes 当前位置
* @param {*} targetPosition 目标位置
*/
function getLocalDistance(locationRes, targetPosition) {
var lat1 = locationRes.latitude;
var lng1 = locationRes.longitude;
var lat2 = targetPosition.latitude;
var lng2 = targetPosition.longitude;
var radLat1 = rad(lat1);
var radLat2 = rad(lat2);
var a = radLat1 - radLat2;
var b = rad(lng1) - rad(lng2);
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * 6378.137;
// s:单位米
s = Math.round(s * 10000);
var kkm = 1000000,
km = 1000;
// dis:文字化单位
var dis = s > kkm ? (s / kkm).toFixed(1) + "千公里" : (s > km ? (s / km).toFixed(1) + "公里" : s + "米");
console.log("s:", s);
console.log("dis:", dis);
return {
s,
dis
};
}
/**
* 获取小程序码
* path = "/pages/index/index?pa=1"
......@@ -232,5 +269,6 @@ module.exports = {
formatWeek: formatWeek,
getBindtapData: getBindtapData,
wxacodeGet: wxacodeGet,
getObjByListKeyValue:getObjByListKeyValue,
getObjByListKeyValue: getObjByListKeyValue,
getLocalDistance: getLocalDistance
}
......