Quellcode durchsuchen

todo tab;安检

王智慧 vor 3 Jahren
Ursprung
Commit
305e22dcd2

+ 0 - 49
cloudfunctions/api/index.js

@@ -28,47 +28,6 @@ exports.main = async (event, context) => {
     await next();
   });
 
-
-  app.router("getWxPhoneNumber", async (ctx, next) => {
-    let {
-      cloudID,
-      encryptedData,
-      errMsg,
-      iv,
-      session_key
-    } = event
-    console.log(event)
-
-    let pc = new WXBizDataCrypt(APPID, session_key)
-
-    let data = pc.decryptData(encryptedData, iv)
-
-    ctx.body = {
-      phone: data.phoneNumber,
-      _openid
-    }
-    await next()
-  })
-
-  app.router("getOpenId", async (ctx, next) => {
-    ctx.body = {
-      openId: _openid
-    }
-    await next()
-  })
-  app.router("sendError", async (ctx, next) => {
-    delete event.$url
-    delete event.userInfo
-    let res = await errorLogs.add({
-      data: {
-        createTime: db.serverDate(),
-        ...event,
-        _openid,
-      }
-    })
-    await next()
-  })
-
   app.router("base", async (ctx, next) => {
 
     await next()
@@ -105,14 +64,6 @@ exports.main = async (event, context) => {
     await next();
   });
 
-
-  app.router("getOpenId", async (ctx, next) => {
-    ctx.data = {
-      openId: _openid
-    }
-    await next();
-  });
-
   app.router("sendMsg", async (ctx, next) => {
     let result = await cloud.openapi.subscribeMessage.send({
       "touser": _openid,

+ 1 - 2
miniprogram/app.js

@@ -1,6 +1,5 @@
 import {
-  wxSetSessionKey,
-  getOpenId
+  wxSetSessionKey
 } from "./utils/wxUtils"
 App({
   onLaunch: function () {

+ 23 - 2
miniprogram/app.json

@@ -2,13 +2,15 @@
   "pages": [
     "pages/index/index",
     "pages/takePhoto/takePhoto",
-    "pages/cachePage/cachePage",
     "pages/takePhoto/success/success",
     "pages/share/share",
     "pages/newCachePage/newCachePage",
     "pages/takeBill/takeBill",
     "pages/takeBill/success/success",
-    "pages/takeBill/canvas/canvas"
+    "pages/takeBill/canvas/canvas",
+    "pages/maritime/maritime",
+    "pages/securityCheck/securityCheck",
+    "pages/train/train"
   ],
   "requiredPrivateInfos": ["getLocation"],
   "window": {
@@ -20,6 +22,25 @@
     "navigationStyle": "custom",
     "pageOrientation": "portrait"
   },
+  "tabBar": {
+    "list": [{
+        "pagePath": "pages/index/index",
+        "text": "拍照"
+      },
+      {
+        "pagePath": "pages/maritime/maritime",
+        "text": "海事"
+      },
+      {
+        "pagePath": "pages/securityCheck/securityCheck",
+        "text": "安检"
+      },
+      {
+        "pagePath": "pages/train/train",
+        "text": "培训"
+      }
+    ]
+  },
   "permission": {
     "scope.userLocation": {
       "desc": "你的位置信息将用于小程序位置接口的效果展示"

+ 0 - 237
miniprogram/pages/cachePage/cachePage.js

@@ -1,237 +0,0 @@
-// pages/cachePage/cachePage.js
-import cloudApi from "../../apis/cloudApi"
-import {
-  postApi
-} from "../../apis/api"
-import {
-  uploadFile
-} from "../../utils/upload"
-
-Page({
-
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    type: "",
-    file: "",
-    latitude: "",
-    longitude: "",
-    shipName: "",
-    shipMmsi: "",
-    agreeModal: false,
-    agreeText: false
-  },
-  goBack() {
-    wx.redirectTo({
-      url: '/pages/index/index',
-    })
-  },
-  checkout() {
-    if (!this.data.shipName) {
-      wx.showToast({
-        title: '请输入船名!',
-        icon: "error"
-      })
-      return
-    }
-
-    if (!this.data.shipMmsi) {
-      wx.showToast({
-        title: '请输入MMSI!',
-        icon: "error"
-      })
-      return
-    }
-
-    return true
-  },
-  agree() {
-    this.setData({
-      agreeText: false,
-    })
-  },
-
-  showAgeeeText() {
-    this.setData({
-      agreeText: true
-    })
-  },
-  hideAgreeText() {
-    this.setData({
-      agreeText: false
-    })
-  },
-  hideAgreeModal() {
-    this.setData({
-      agreeModal: false
-    })
-  },
-  showAgreeModal() {
-    // if (!this.checkout()) return
-    this.setData({
-      agreeModal: true
-    })
-  },
-  async getPhoneNumber(e) {
-    try {
-      if (e.detail.errMsg == "getPhoneNumber:ok") {
-        wx.showLoading({
-          title: '正在登录...',
-          mask: true
-        })
-        let session_key = wx.getStorageSync('session_key')
-        let {
-          result
-        } = await cloudApi("getWxPhoneNumber", {
-          ...e.detail,
-          session_key
-        })
-        let {
-          phone,
-        } = result
-        if (phone) {
-          wx.setStorageSync('phone', phone)
-          let {
-            shipName,
-            shipMmsi
-          } = this.data
-          try {
-            let res = await uploadFile(wx.getStorageSync('file'), {
-              openId: wx.getStorageSync('openId'),
-              phone,
-              shipName,
-              shipMmsi,
-              type: wx.getStorageSync('type'),
-              location: `${this.data.longitude},${this.data.latitude}`
-            }, 1)
-            if (res.status == 0) {
-              wx.setStorageSync('shareImageUrl', res.result.mediaInfo.viewUrl)
-              let {
-                shipInfo,
-                userInfo
-              } = res.result
-
-              let data = {
-                ...shipInfo,
-                ...userInfo
-              }
-              Object.keys(data).forEach(function (key) {
-                wx.setStorageSync(key, data[key])
-              })
-              wx.showToast({
-                title: res.msg,
-              })
-              wx.downloadFile({
-                url: res.result.mediaInfo.viewUrl,
-                success: e => {
-                  console.log("下载调用!", e)
-                  wx.setStorageSync('cacheImage', e.tempFilePath)
-                  wx.saveImageToPhotosAlbum({
-                    filePath: e.tempFilePath,
-                    success: e => {
-                      console.log(5, e)
-
-                      if (e.errMsg == "saveImageToPhotosAlbum:ok") {
-                        wx.showToast({
-                          title: '保存成功!',
-                        })
-                        wx.removeStorageSync('cacheImage')
-                      }
-                    },
-                    fail: async e => {
-                      console.log("6", e)
-                      wx.hideLoading({})
-                      wx.showToast({
-                        title: '保存失败!',
-                        duration: 5000
-                      })
-                      await cloudApi('sendError', {
-                        e,
-                        flag: 4,
-                        msg: "保存失败"
-                      })
-                      this.setData({
-                        authModal: true,
-                        modalText: "文件存储"
-                      })
-                    }
-                  })
-                  wx.navigateTo({
-                    url: '/pages/takePhoto/success/success',
-                  })
-                },
-                fail: async e => {
-                  wx.hideLoading({})
-                  wx.showToast({
-                    title: '下载失败!',
-                    duration: 5000
-                  })
-                  await cloudApi('sendError', {
-                    e,
-                    msg: "下载失败",
-                    flag: 3
-                  })
-                }
-              })
-            } else {
-              wx.hideLoading({})
-              await cloudApi('sendError', {
-                res,
-                flag: 2
-              })
-              wx.showToast({
-                title: res.msg,
-                icon: "error"
-              })
-            }
-          } catch (error) {
-            await cloudApi('sendError', {
-              error,
-              flag: 1
-            })
-          }
-        } else {
-          wx.hideLoading({})
-          wx.showToast({
-            title: '获取手机号失败',
-            duration: 5000
-          })
-          await cloudApi('sendError', {
-            msg: "获取手机号失败"
-          })
-        }
-      } else {
-        wx.showToast({
-          title: '请授权以登录',
-          icon: "error"
-        })
-        await cloudApi('sendError', {
-          msg: "未授权手机号"
-        })
-      }
-    } catch (error) {
-      await cloudApi('sendError', {
-        msg: "全局trycatch",
-        error
-      })
-    }
-
-
-  },
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: function (options) {
-    this.setData({
-      type: wx.getStorageSync('type'),
-      file: wx.getStorageSync('file'),
-      latitude: wx.getStorageSync('latitude'),
-      longitude: wx.getStorageSync('longitude')
-    })
-  },
-
-  onShareAppMessage: function () {
-
-  }
-})

+ 0 - 52
miniprogram/pages/cachePage/cachePage.wxml

@@ -1,52 +0,0 @@
-<view class="main-container">
-  <image class="media-container" mode="aspectFit" wx:if="{{type==1}}" src="{{file}}"> </image>
-  <video class="media-container" autoplay="{{true}}" wx:else src="{{file}}"></video>
-</view>
-<view class="line mb30">
-  <view class="ship-name">船舶名称 : </view><input class="ship-name-ipt" model:value="{{shipName}}" type="text" placeholder="请输入船舶名称" />
-</view>
-<view class="line">
-  <view class="ship-mmsi">MMSI : </view><input class="ship-mmsi-ipt" model:value="{{shipMmsi}}" type="text" placeholder="请输入MMSI" />
-</view>
-<view>
-  <button style="width: 600rpx;height: 90rpx;line-height: 90rpx;background: #3e94f6;border-radius: 45rpx;padding: 0;margin-top: 30rpx;" bindtap="showAgreeModal" type="primary">注册/登录</button>
-  <button style="width: 500rpx;height: 60rpx;line-height: 60rpx;background: #777;border-radius: 30rpx;padding: 0;margin-top: 30rpx;font-size: 24rpx;" bindtap="goBack" type="primary">返回继续体验</button>
-</view>
-<view wx:if="{{agreeText}}" style="position: absolute;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(000, 000, 000, 0.5);z-index: 10;">
-  <scroll-view style="height: 90vh;width: 90vw;background-color: #fff;margin: 5vh auto;padding: 20rpx;" scroll-y="true">
-    <view style="font-size:large;text-align: center;margin:60rpx;">隐私协议</view>
-    <text space="ensp" decode="true">&nbsp;&nbsp;</text>
-    <text space="ensp" decode="true">&nbsp;&nbsp;本隐私政策介绍本公司的隐私数据相关政策和惯例,包括在使用汇很多小程序时上传至云端的数据将受到保护,防止以及追究某些非法手段获取本公司所保管的关于您的数据资料。请你仔细阅读我们的隐私政策。
-    </text><text space="ensp" decode="true">一、本公司如何收集您的个人信息汇很多小程序以个人电话号码作为唯一身份识别方式,用于个人登录使用以及密码遗忘、找回的唯一途径。当您使用本公司的微信小程序,注册过程中我们将仅收集您的电话号码作为唯一身份识别,使用期间终身有效。
-    </text><text space="ensp" decode="true">二、本公司如何使用您的个人信息
-      1、通过您的手机号码实现密码找回功能。
-      2、本公司不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和本公司单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些信息。
-    </text><text space="ensp" decode="true">三、个人信息安全
-      保证您的数据的安全对我们来说至关重要。当您在本公司的微信小程序中注册输入个人信息时,我们对这些信息进行加密。
-      在数据传输和数据保管两个阶段里,我们会通过广为接受的行业标准(如防火墙、加密和数据隐私法律要求)来保护您向我们提交的信息。
-      然而,没有任何一种互联网传输或电子存储方法是100%安全的。因此,尽管我们通过商业上可接受的方式来保护您的个人信息,但仍无法保证信息的绝对安全。
-    </text><text space="ensp" decode="true">四、本公司会将个人信息保存多久
-      一般来说,本公司仅在您使用本公司微信小程序期间保留您的个人信息,同时将遵守适用法律规定的数据保留期限。
-    </text><text space="ensp" decode="true">五、法律免责声明
-      在法律要求的情况下(如协助公安机关)或遵守司法程序、法院指令,以及因用户行为而致使本公司的法定权益收到威胁,或适用于本公司的微信小程序的法律程序时,我们有权透露您的个人信息。
-      如果本公司确定为了执行本公司的条款和条件或保护我们的经营,披露是合理必须的,则我们可能会披露与您有关的信息。
-    </text><text space="ensp" decode="true">六、本隐私政策的更改
-      本公司会根据国家法律法规不定时更改本政策协议。修改执行之前,本公司将会在小程序用户协议、以及本公司网站通知本次政策更改,以便您了解我们如何收集、使用您的个人信息,哪些人可以访问这些信息,以及在什么情况下我们会披露这些信息。
-      本公司保留随时修改本政策的权利,因此请经常查看。
-    </text><text space="ensp" decode="true">七、隐私问题
-      如果你对本公司的隐私政策或数据处理有任何问题或顾虑,请通过+86 18049981341与本公司联系。
-    </text>
-
-    <button bindtap="agree" type="primary">确定</button>
-  </scroll-view>
-</view>
-<view style="position: absolute;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(000, 000, 000, 0.5);z-index: 8;" wx:if="{{agreeModal}}">
-  <view style="width:80vw;height:60vw;background:#fff;border-radius: 50rpx;padding: 50rpx;color: #333;font-size: 30rpx;margin: 60% auto;">
-    <view style="text-align: center;font-size: 36rpx;margin-bottom:20rpx ;">隐私协议提示</view>
-    <view>感谢您的信任并使用汇很多小程序,请务必阅读 <text bindtap="showAgeeeText" style="text-decoration: underline;color: orange;">《隐私协议》</text>各条款,若继续使用请点击下方按钮“同意并继续”。</view>
-    <view style="display: flex;justify-content: space-around;align-items: center;margin-top: 50rpx;">
-      <view style="width: 200rpx;height:80rpx;background: #eee;border-radius: 40rpx;text-align: center;line-height: 80rpx;color: #000;font-size: 28rpx;margin:0" bindtap="hideAgreeModal">取消</view>
-      <button style="    width: 200rpx;height: 80rpx;background: #333;border-radius: 40rpx;text-align: center;line-height: 80rpx;color: #fff;font-size: 28rpx;font-weight: normal;padding: 0;margin: 0;" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">同意并继续</button>
-    </view>
-  </view>
-</view>

+ 0 - 50
miniprogram/pages/cachePage/cachePage.wxss

@@ -1,50 +0,0 @@
-/* pages/cachePage/cachePage.wxss */
-.main-container {
-  height: 55vh;
-  width: 80vw;
-  margin: 0 auto;
-  margin-top: 10vh;
-  margin-bottom: 3vh;
-}
-
-.media-container {
-  width: 100%;
-  height: 100%;
-}
-
-
-
-.ship-name,
-.ship-mmsi {
-  width: 153rpx;
-  height: 36rpx;
-  font-size: 30rpx;
-  font-family: PingFangSC-Regular,
-    PingFang SC;
-  font-weight: 400;
-  color: #333333;
-  line-height: 36rpx;
-  text-align: right;
-  margin-right: 6rpx;
-}
-
-.ship-name-ipt,
-.ship-mmsi-ipt {
-  width: 420rpx;
-  height: 67rpx;
-  border: 1px solid #979797;
-  font-size: 30rpx;
-  padding-left: 20rpx;
-}
-
-.submit {
-  margin-top: 130rpx;
-  height: 80rpx;
-  background: #0094FE;
-  border-radius: 4rpx;
-  font-size: 34rpx;
-  font-family: PingFangSC-Regular,
-    PingFang SC;
-  font-weight: 400;
-  color: #FFFFFF;
-}

+ 0 - 1
miniprogram/pages/index/index.js

@@ -1,5 +1,4 @@
 // pages/index/index.js
-import cloudApi from "../../apis/cloudApi"
 import {
   postApi
 } from "../../apis/api"

+ 66 - 0
miniprogram/pages/maritime/maritime.js

@@ -0,0 +1,66 @@
+// pages/maritime/maritime.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 0 - 0
miniprogram/pages/cachePage/cachePage.json → miniprogram/pages/maritime/maritime.json


+ 2 - 0
miniprogram/pages/maritime/maritime.wxml

@@ -0,0 +1,2 @@
+<!--pages/maritime/maritime.wxml-->
+<text>pages/maritime/maritime.wxml</text>

+ 1 - 0
miniprogram/pages/maritime/maritime.wxss

@@ -0,0 +1 @@
+/* pages/maritime/maritime.wxss */

+ 8 - 17
miniprogram/pages/newCachePage/newCachePage.js

@@ -171,16 +171,15 @@ Page({
           title: '正在登录...',
           mask: true
         })
-        let session_key = wx.getStorageSync('session_key')
+
         let {
-          result
-        } = await cloudApi("getWxPhoneNumber", {
-          ...e.detail,
-          session_key
+          data
+        } = await postApi('/wx/getPhoneNumber', {
+          code: e.detail.code
         })
         let {
-          phone,
-        } = result
+          phoneNumber: phone
+        } = data.result
         if (phone) {
           wx.setStorageSync('phone', phone)
           try {
@@ -298,24 +297,16 @@ Page({
             title: '获取手机号失败',
             duration: 5000
           })
-          await cloudApi('sendError', {
-            msg: "获取手机号失败"
-          })
         }
       } else {
         wx.showToast({
           title: '请授权以登录',
           icon: "error"
         })
-        await cloudApi('sendError', {
-          msg: "未授权手机号"
-        })
+
       }
     } catch (error) {
-      await cloudApi('sendError', {
-        msg: "全局trycatch",
-        error
-      })
+
     }
 
 

+ 66 - 0
miniprogram/pages/securityCheck/securityCheck.js

@@ -0,0 +1,66 @@
+// pages/securityCheck/securityCheck.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 3 - 0
miniprogram/pages/securityCheck/securityCheck.json

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

+ 2 - 0
miniprogram/pages/securityCheck/securityCheck.wxml

@@ -0,0 +1,2 @@
+<!--pages/securityCheck/securityCheck.wxml-->
+<text>pages/securityCheck/securityCheck.wxml</text>

+ 1 - 0
miniprogram/pages/securityCheck/securityCheck.wxss

@@ -0,0 +1 @@
+/* pages/securityCheck/securityCheck.wxss */

+ 66 - 0
miniprogram/pages/train/train.js

@@ -0,0 +1,66 @@
+// pages/train/train.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 3 - 0
miniprogram/pages/train/train.json

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

+ 2 - 0
miniprogram/pages/train/train.wxml

@@ -0,0 +1,2 @@
+<!--pages/train/train.wxml-->
+<text>pages/train/train.wxml</text>

+ 1 - 0
miniprogram/pages/train/train.wxss

@@ -0,0 +1 @@
+/* pages/train/train.wxss */

+ 12 - 15
miniprogram/utils/wxUtils.js

@@ -1,17 +1,23 @@
 import cloudApi from "../apis/cloudApi"
+import {
+  postApi
+} from "../apis/api"
 
 function wxSetSessionKey() {
   return new Promise((resolve, reject) => {
     wx.login({
       success: async res => {
-        let res1 = await cloudApi('code2Session', {
-          JSCODE: res.code
+        let {
+          data
+        } = await postApi('/wx/getOpenId', {
+          code: res.code
         })
-        wx.setStorageSync('session_key', res1.result.session_key)
-        wx.setStorageSync('openId', res1.result._openid)
+        let {
+          result: openId
+        } = data
+        wx.setStorageSync('openId', openId)
         resolve({
-          session_key: res1.result.session_key,
-          openId: res1.result._openid
+          openId
         })
       }
     })
@@ -42,14 +48,6 @@ function getUserProfile() {
   })
 }
 
-function getOpenId() {
-  return new Promise(async (resolve, reject) => {
-    let res1 = await cloudApi('getOpenId')
-    resolve(res1.result.openId)
-  })
-
-}
-
 function subMsg() {
   return new Promise((resolve, reject) => {
     wx.requestSubscribeMessage({
@@ -67,6 +65,5 @@ function subMsg() {
 module.exports = {
   wxSetSessionKey,
   getUserProfile,
-  getOpenId,
   subMsg
 }

+ 7 - 0
project.private.config.json

@@ -59,6 +59,13 @@
           "query": "",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/newCachePage/newCachePage",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }