| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- // 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) {
- if (e.detail.errMsg == "getPhoneNumber:ok") {
- wx.showLoading({
- title: '正在登录...',
- })
- let session_key = wx.getStorageSync('session_key')
- let {
- result
- } = await cloudApi("getWxPhoneNumber", {
- ...e.detail,
- session_key
- })
- let {
- phone,
- } = result
- let {
- shipName,
- shipMmsi
- } = this.data
- console.log(phone,
- shipName,
- shipMmsi, )
- 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)
- wx.setStorageSync('shareImageUrl', res.result.mediaInfo.viewUrl)
- if (res.status == 0) {
- 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.redirectTo({
- url: '/pages/takePhoto/takePhoto',
- })
- } else {
- wx.showToast({
- title: res.msg,
- icon: "error"
- })
- }
- } else {
- wx.showToast({
- title: '请授权以登录',
- icon: "error"
- })
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- type: wx.getStorageSync('type'),
- file: wx.getStorageSync('file'),
- latitude: wx.getStorageSync('latitude'),
- longitude: wx.getStorageSync('longitude')
- })
- },
- onShareAppMessage: function () {
- }
- })
|