Browse Source

feat: 新增扫码核销页面

test
jiannibang 3 years ago
parent
commit
1dae0794f2
  1. 3
      app.json
  2. 2
      getMapData.js
  3. 4
      pages/scanCode/back.svg
  4. 3
      pages/scanCode/border.svg
  5. 4
      pages/scanCode/close.svg
  6. 80
      pages/scanCode/index.js
  7. 3
      pages/scanCode/index.json
  8. 9
      pages/scanCode/index.wxml
  9. 71
      pages/scanCode/index.wxss
  10. 9
      pages/scanCode/scaner.svg
  11. 3
      project.config.json
  12. 7
      project.private.config.json

3
app.json

@ -4,7 +4,8 @@
"pages/index/index", "pages/index/index",
"pages/login/index", "pages/login/index",
"pages/privacy/index", "pages/privacy/index",
"pages/detail/index"
"pages/detail/index",
"pages/scanCode/index"
], ],
"window": { "window": {
"navigationStyle": "custom", "navigationStyle": "custom",

2
getMapData.js

@ -8,7 +8,7 @@ export const cdnUrl = "https://test-598d.1000my.com";
const baseUrl = "https://project-iot.test.1000my.com"; const baseUrl = "https://project-iot.test.1000my.com";
export const code = "project-skcn0gk6yb2xutkcsmjtra"; export const code = "project-skcn0gk6yb2xutkcsmjtra";
export const post = (url, data) => export const post = (url, data) =>
new Promise((resolve) => {
new Promise((resolve, reject) => {
wx.request({ wx.request({
url: baseUrl + url, url: baseUrl + url,
method: "POST", method: "POST",

4
pages/scanCode/back.svg

@ -0,0 +1,4 @@
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="60" height="60" rx="10" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M35.0976 18.0794C35.7903 18.6855 35.8605 19.7385 35.2544 20.4312L26.8813 30.0003L35.2544 39.5695C35.8605 40.2622 35.7903 41.3152 35.0976 41.9213C34.4048 42.5274 33.3519 42.4573 32.7458 41.7645L23.7966 31.5369C23.0268 30.6571 23.0268 29.3436 23.7966 28.4638L32.7458 18.2362C33.3519 17.5434 34.4048 17.4733 35.0976 18.0794Z" fill="#353230"/>
</svg>

After

Width:  |  Height:  |  Size: 544 B

3
pages/scanCode/border.svg

@ -0,0 +1,3 @@
<svg width="320" height="320" viewBox="0 0 320 320" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.86102e-06 0H30V4H4L4 30H2.86102e-06V0ZM320 0V30H316V4L290 4V0H320ZM290 320H320V290H316V316H290V320ZM0 320V290H4L4 316H30V320H0Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 303 B

4
pages/scanCode/close.svg

@ -0,0 +1,4 @@
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.0001 22.5858L28.9501 17.6357C29.3406 17.2453 29.9737 17.2453 30.3641 17.6357C30.7546 18.0262 30.7546 18.6593 30.3641 19.0497L25.4141 23.9998L30.364 28.9497C30.7545 29.3402 30.7545 29.9733 30.364 30.3637C29.9736 30.7542 29.3405 30.7542 28.95 30.3637L24.0001 25.4138L19.0502 30.3636C18.6597 30.7541 18.0267 30.7541 17.6362 30.3636C17.2457 29.9732 17.2457 29.3401 17.6362 28.9496L22.5861 23.9998L17.6362 19.0497C17.2457 18.6592 17.2457 18.0262 17.6362 17.6357C18.0267 17.2453 18.6597 17.2453 19.0502 17.6357L24.0001 22.5858Z" fill="white"/>
<rect x="1" y="1" width="46" height="46" rx="23" stroke="white" stroke-opacity="0.4" stroke-width="2"/>
</svg>

After

Width:  |  Height:  |  Size: 758 B

80
pages/scanCode/index.js

@ -0,0 +1,80 @@
import { post } from "../../getMapData";
Page({
/**
* 页面的初始数据
*/
data: {},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
async handleCode(e) {
try {
const memberID = getApp().globalData.memberID;
const { code, msg } = await post("/api/ar/v1/applet/writeoffcoupon", {
orderNo: e.detail.result,
memberID,
});
if (code === 200) {
wx.showToast({
icon: "none",
title: "核销成功",
});
setTimeout(() => {
wx.redirectTo({
url: "/pages/h5map/index?e=writeoff",
});
}, 1000);
} else {
wx.showToast({
icon: "none",
title: msg,
});
return false;
}
} catch (error) {
return false;
}
},
back() {
wx.redirectTo({
url: "/pages/h5map/index?e=writeoff",
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});

3
pages/scanCode/index.json

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

9
pages/scanCode/index.wxml

@ -0,0 +1,9 @@
<view class="scanCode">
<image class="border" src="./border.svg"> </image>
<image class="scaner" src="./scaner.svg"></image>
<camera class="camera" mode="scanCode" device-position="back" bindscancode="handleCode" style="width: 280px; height: 280px;" />
<view class="btn" bindtap="back">
手动输入券码
</view>
<image class="back" src="./close.svg" bindtap="back"></image>
</view>

71
pages/scanCode/index.wxss

@ -0,0 +1,71 @@
.scanCode {
position: relative;
width: 100vw;
height: 100vh;
background: #353230;
}
.back {
position: absolute;
bottom: 48px;
left: 0;
right: 0;
margin: auto;
width: 48px;
height: 48px;
}
.btn {
position: absolute;
height: 56px;
left: 29px;
right: 28px;
bottom: 130px;
background: #ffffff;
border-radius: 10px;
font-weight: 600;
font-size: 16px;
line-height: 22px;
color: #437af7;
display: flex;
justify-content: center;
align-items: center;
}
@keyframes scaner {
0% {
top: 10px;
}
100% {
top: 340px;
}
}
.border {
position: absolute;
top: 94px;
left: 0;
right: 0;
margin: auto;
width: 320px;
height: 320px;
z-index: 1;
}
.scaner {
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 320px;
height: 74px;
animation: 1s scaner infinite ease-in-out;
z-index: 3;
pointer-events: none;
}
.camera {
position: absolute;
top: 114px;
left: 0;
right: 0;
margin: auto;
width: 280px;
height: 280px;
z-index: 2;
}

9
pages/scanCode/scaner.svg

@ -0,0 +1,9 @@
<svg width="320" height="74" viewBox="0 0 320 74" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="320" height="74" fill="url(#paint0_linear_1115_21600)"/>
<defs>
<linearGradient id="paint0_linear_1115_21600" x1="160" y1="0" x2="160" y2="74" gradientUnits="userSpaceOnUse">
<stop stop-color="#437AF7" stop-opacity="0"/>
<stop offset="1" stop-color="#437AF7" stop-opacity="0.7"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 424 B

3
project.config.json

@ -36,7 +36,8 @@
"showES6CompileOption": false, "showES6CompileOption": false,
"useCompilerPlugins": false, "useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true, "ignoreUploadUnusedFiles": true,
"useStaticServer": true
"useStaticServer": true,
"condition": false
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"condition": { "condition": {

7
project.private.config.json

@ -18,6 +18,13 @@
"query": "e=activities026eb3c7-41a7-4e07-bd4a-07e3d9dc3af1", "query": "e=activities026eb3c7-41a7-4e07-bd4a-07e3d9dc3af1",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
},
{
"name": "",
"pathName": "pages/scanCode/index",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }

Loading…
Cancel
Save