index.js
7.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
"use strict";
const common_vendor = require("../../common/vendor.js");
const ty_index = require("../../ty/index.js");
const store_user = require("../../store/user.js");
require("../../ty/api/index.js");
require("../../ty/api/user.js");
require("../../ty/request/index.js");
require("../../ty/config/index.js");
require("../../store/index.js");
require("../../store/wxInfo.js");
require("../../ty/router/index.js");
require("../../ty/helper/throttle.js");
require("../../ty/helper/index.js");
require("../../ty/helper/test.js");
require("../../ty/helper/digit.js");
require("../../ty/wechat/wechat.js");
if (!Array) {
const _easycom_u__text2 = common_vendor.resolveComponent("u--text");
const _easycom_u_input2 = common_vendor.resolveComponent("u-input");
const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
(_easycom_u__text2 + _easycom_u_input2 + _easycom_u_button2)();
}
const _easycom_u__text = () => "../../uni_modules/uview-plus/components/u--text/u--text.js";
const _easycom_u_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
const _easycom_u_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
if (!Math) {
(_easycom_u__text + _easycom_u_input + _easycom_u_button)();
}
const _sfc_main = {
__name: "index",
setup(__props) {
const store = store_user.user();
let isShowMore = common_vendor.ref(false);
let appid = common_vendor.ref("wx1c3cc5b4e2006be2");
let callbackurl = common_vendor.ref("https://coupon.xp.yn.cn/h5");
let actId = common_vendor.ref("");
let activeData = common_vendor.reactive({ value: {} });
let activeList = common_vendor.reactive([]);
let activeListLong = common_vendor.reactive([]);
let payFrom = common_vendor.reactive({
name: "",
phone: ""
});
let showMore = () => {
isShowMore.value = true;
activeList = activeListLong;
};
let goActivity = () => {
ty_index.ty.$router.go("/pages/activity/activity");
};
const getUrlCode = (name) => {
return decodeURIComponent((new RegExp("[?|&]" + name + "=([^&;]+?)(&|#|;|$)").exec(location.href) || [
,
""
])[1].replace(/\+/g, "%20")) || null;
};
const is_weixin = () => {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
};
const checkWeChatCode = () => {
let code = getUrlCode("code");
if (store.isLogin)
return;
if (code) {
console.log("有code,这里获取用户信息");
ty_index.ty.$api.user.getUserInfo({
code
}).then((res) => {
common_vendor.index.setStorageSync("useInfo", res.data.user_info);
store.setToken(res.data.token);
});
} else {
console.log("没有code");
getCode();
}
};
const getCode = () => {
let code = getUrlCode("code");
console.log(code, "code");
if (code === null || code === "") {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid.value + "&redirect_uri=" + encodeURIComponent(callbackurl.value) + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
} else {
code = code;
}
};
const getAct = () => {
ty_index.ty.$api.user.getActivity({ store_id: store.store_id }).then((res) => {
activeData.value = res.data;
actId.value = res.data.id;
getUserList(res.data.id);
});
};
const getUserList = (id) => {
ty_index.ty.$api.user.getActUserList({ store_id: store.store_id, id }).then((res) => {
activeList = res.data.data;
activeListLong = res.data.data;
if (res.data.data.length < 6) {
isShowMore.value = true;
} else {
activeList = res.data.data.slice(0, 6);
isShowMore.value = false;
}
});
};
const createPayOrder = async () => {
if (payFrom.name == "" || payFrom.phone == "") {
common_vendor.index.showToast({
title: "请输入姓名或手机号",
icon: "none"
});
return;
}
let params = {
verification_activity_id: actId.value,
store_id: store.store_id,
...payFrom
};
let res = await ty_index.ty.$api.user.createOrder(params);
let data = res.data;
console.log(data);
};
common_vendor.onLoad(async () => {
getAct();
let flag = is_weixin();
if (flag) {
checkWeChatCode();
console.log("是微信浏览器");
} else {
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0fbe9ddb5750461b";
console.log("不是微信浏览器");
}
});
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.p({
text: "活动门店",
margin: "0 60rpx 0 0",
type: "tips"
}),
b: common_vendor.o(($event) => common_vendor.unref(activeData).value.name = $event),
c: common_vendor.p({
placeholder: "",
disabled: true,
modelValue: common_vendor.unref(activeData).value.name
}),
d: common_vendor.p({
text: "门店地址",
margin: "0 60rpx 0 0",
type: "tips"
}),
e: common_vendor.o(($event) => common_vendor.unref(activeData).value.address = $event),
f: common_vendor.p({
placeholder: "",
suffixIcon: "map-fill",
suffixIconStyle: "color: #909399",
disabled: true,
modelValue: common_vendor.unref(activeData).value.address
}),
g: common_vendor.p({
text: "门店电话",
margin: "0 60rpx 0 0",
type: "tips"
}),
h: common_vendor.o(($event) => common_vendor.unref(activeData).value.phone = $event),
i: common_vendor.p({
placeholder: "",
suffixIcon: "phone-fill",
suffixIconStyle: "color: #909399",
disabled: true,
modelValue: common_vendor.unref(activeData).value.phone
}),
j: common_vendor.p({
text: "姓名",
margin: "0 120rpx 0 0",
type: "tips"
}),
k: common_vendor.o(($event) => common_vendor.unref(payFrom).name = $event),
l: common_vendor.p({
placeholder: "请输入",
modelValue: common_vendor.unref(payFrom).name
}),
m: common_vendor.p({
text: "手机号",
margin: "0 90rpx 0 0",
type: "tips"
}),
n: common_vendor.o(($event) => common_vendor.unref(payFrom).phone = $event),
o: common_vendor.p({
placeholder: "请输入",
modelValue: common_vendor.unref(payFrom).phone
}),
p: common_vendor.o(createPayOrder),
q: common_vendor.p({
type: "primary",
text: "立即支付"
}),
r: common_vendor.f(common_vendor.unref(activeList), (item, index, i0) => {
return {
a: common_vendor.t(item.sort),
b: common_vendor.t(item.name),
c: common_vendor.t(item.createtime),
d: common_vendor.n(index % 2 == 0 && "listBg"),
e: index
};
}),
s: !common_vendor.unref(isShowMore)
}, !common_vendor.unref(isShowMore) ? {
t: common_vendor.o((...args) => common_vendor.unref(showMore) && common_vendor.unref(showMore)(...args))
} : {}, {
v: common_vendor.o((...args) => common_vendor.unref(goActivity) && common_vendor.unref(goActivity)(...args))
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "D:/xiangmu/kajuan/pages/index/index.vue"]]);
wx.createPage(MiniProgramPage);