Преглед изворни кода

feat: add work & permission pages

wangyuan пре 2 година
родитељ
комит
375bd30912

+ 79 - 0
pages/permissions/permissions.js

@@ -0,0 +1,79 @@
+// pages/permissions/permissions.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    scanFlag: true
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  bindscancode(e) {
+    var that = this
+    if (that.data.scanFlag) {
+      var response = e.detail.result
+      console.log(response, 'response');
+      that.setData({
+        scanFlag: false
+      })
+      wx.showModal({
+        content: '权限登录成功',
+        confirmColor: '#333',
+        showCancel: false
+      })
+    }
+  },
+
+  bindscanerror () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 3 - 0
pages/permissions/permissions.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "获取权限"
+}

+ 13 - 0
pages/permissions/permissions.wxml

@@ -0,0 +1,13 @@
+<!--pages/permissions/permissions.wxml-->
+<view class="permission wh">
+  <view class="canmer-box">
+    <camera device-position="back" flash="off" mode="scanCode" bindscancode="bindscancode" binderror="bindscanerror" style="width: 100%; height: 100%;"></camera>
+    <!-- <view class="top-modal"></view>
+    <view class="bottom-modal"></view>
+    <view class="left-modal"></view>
+    <view class="right-modal"></view> -->
+  </view>
+  <view class="actions">
+    <view class="tips">教程</view>
+  </view>
+</view>

+ 47 - 0
pages/permissions/permissions.wxss

@@ -0,0 +1,47 @@
+/* pages/permissions/permissions.wxss */
+.canmer-box {
+  width: 750rpx;
+  height: 900rpx;
+  position: relative;
+}
+.top-modal {
+  width: 100%;
+  height: 150rpx;
+  background: #000000;
+  opacity: 0.5;
+  position: absolute;
+  top: 0;
+}
+.bottom-modal {
+  width: 100%;
+  height: 150rpx;
+  background: #000000;
+  opacity: 0.5;
+  position: absolute;
+  bottom: 0;
+}
+.left-modal {
+  width: 75rpx;
+  height: 603rpx;
+  background: #000000;
+  opacity: 0.5;
+  position: absolute;
+  left: 0;
+  top: 150rpx;
+}
+.right-modal {
+  width: 75rpx;
+  height: 603rpx;
+  background: #000000;
+  opacity: 0.5;
+  position: absolute;
+  right: 0;
+  bottom: 150rpx;
+}
+.tips {
+  font-size: 30rpx;
+  font-weight: bold;
+  color: #333333;
+  text-indent: 30rpx;
+  margin-top: 30rpx;
+}

+ 78 - 0
pages/workbench/workbench.js

@@ -0,0 +1,78 @@
+// pages/workbench/workbench.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    scanFlag: true,
+    overlayShow: false
+  },
+
+  bindscancode (e) {
+    var that = this
+    if (that.data.scanFlag) {
+      var response = e.detail.result
+      console.log(response, 'response');
+      that.setData({
+        scanFlag: false
+      })
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  handlecancel() {
+    this.setData({
+      overlayShow: false
+    })
+  },
+
+  handlesubmit() {
+    /* wx.showLoading({
+      title: '加载中...',
+      mask: true
+    }) */
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+  
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 3 - 0
pages/workbench/workbench.json

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

+ 55 - 0
pages/workbench/workbench.wxml

@@ -0,0 +1,55 @@
+<!--pages/workbench/workbench.wxml-->
+<view class="work-content wh">
+  <view class="account-info  ittflex-jcs">
+    <view class="left half ittflex-jcs">
+      <view class="head-img"></view>
+      <view class="userinfo">
+        <view class="username">范一岚</view>
+        <view class="usernum">18626576880</view>
+      </view>
+    </view>
+    <view class="right half">
+      <view class="text">
+        <view class="basetext">当前已获得</view>
+        <view class="basetext">测试测试测试检测车权限</view>
+      </view>
+      <view class="arror">
+        <image class="wh" src="../../images/you.png"></image>
+      </view>
+    </view>
+  </view>
+  <view class="tips">核销用户检测次数</view>
+  <view class="camera">
+    <camera device-position="back" flash="off" mode="scanCode" bindscancode="bindscancode" binderror="error" style="width: 100%; height: 100%;"></camera>
+  </view>
+  <view class="overlay wh" wx:if="{{overlayShow}}">
+    <view class="modal">
+      <view class="title">用户信息</view>
+      <view class="username info">
+        <text>姓名:</text>
+        <text class="codename">测试用户</text>
+      </view>
+      <view class="info sex">
+        <text>性别:</text>
+        <text>男</text>
+      </view>
+      <view class="info day">
+        <text>出生年月:</text>
+        <text>2022-09</text>
+      </view>
+      <view class="info age">
+        <text>年龄:</text>
+        <text>22岁</text>
+      </view>
+      <view class="info count">
+        <text>剩余次数:</text>
+        <text class="bold">5</text>
+        <text>次</text>
+      </view>
+      <view class="btn ittflex-jcs">
+        <view class="itt-btn cancel" bindtap="handlecancel">取消</view>
+        <view class="itt-btn submit" bindtap="handlesubmit">确认检测</view>
+      </view>
+    </view>
+  </view>
+</view>

+ 111 - 0
pages/workbench/workbench.wxss

@@ -0,0 +1,111 @@
+/* pages/workbench/workbench.wxss */
+.work-content {
+  background-color: #F7F7F7;
+  padding-top: 1rpx;
+  position: relative;
+}
+.account-info {
+  width: 690rpx;
+  height: 160rpx;
+  margin: 20rpx auto 0;
+  background: #FFFFFF;
+  border-radius: 20rpx;
+}
+.half {
+  width: 50%;
+  height: 100%;
+}
+.head-img {
+  width: 80rpx;
+  height: 80rpx;
+  border-radius: 50%;
+  background-color: #f66;
+  margin: 0 14rpx 0 20rpx;
+}
+.username {
+  font-size: 30rpx;
+  font-weight: bold;
+  color: #333333;
+}
+.usernum {
+  font-size: 26rpx;
+  font-weight: 400;
+  color: #999999;
+}
+.basetext {
+  font-size: 26rpx;
+  font-weight: 400;
+  color: #45A6B5;
+  text-align: right;
+}
+.arror {
+  width: 14rpx;
+  height: 25rpx;
+  margin: 0 20rpx;
+}
+.right {
+  display: flex;
+  justify-content: flex-end;
+  align-items: center;
+}
+.tips {
+  width: 690rpx;
+  margin: 40rpx auto 20rpx;
+  font-size: 30rpx;
+  font-weight: bold;
+  color: #333333;
+}
+.camera {
+  width: 100%;
+  height: 700rpx;
+}
+.overlay {
+  position: absolute;
+  top: 0;
+  background-color: rgba(0,0,0,0.3);
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.modal {
+  width: 558rpx;
+  height: 584rpx;
+  background: #FFFFFF;
+  border-radius: 20rpx;
+}
+.title {
+  font-size: 30rpx;
+  font-weight: bold;
+  color: #333333;
+  text-align: center;
+  margin-top: 20rpx;
+  margin-bottom: 40rpx;
+}
+.info {
+  font-size: 30rpx;
+  font-weight: 400;
+  color: #333333;
+  text-indent: 48rpx;
+  margin-bottom: 20rpx;
+}
+.bold {
+  font-size: 48rpx;
+  font-weight: bold;
+}
+.age {
+  margin-bottom: 10rpx;
+}
+.btn {
+  margin-top: 50rpx;
+}
+.itt-btn {
+  width: 210rpx;
+  height: 68rpx;
+  border-radius: 10rpx;
+}
+.cancel {
+  margin: 0 40rpx 0 48rpx;
+  background-color: #fff;
+  color: #333333;
+  border: 1rpx solid #333333;
+}

+ 7 - 17
utils/util.js

@@ -1,19 +1,9 @@
-const formatTime = date => {
-  const year = date.getFullYear()
-  const month = date.getMonth() + 1
-  const day = date.getDate()
-  const hour = date.getHours()
-  const minute = date.getMinutes()
-  const second = date.getSeconds()
 
-  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
-}
-
-const formatNumber = n => {
-  n = n.toString()
-  return n[1] ? n : `0${n}`
-}
-
-module.exports = {
-  formatTime
+export default {
+  // UUID
+  getUUID () {
+    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
+      return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
+    })
+  }
 }