ada19efb by simon

版本提交

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