|
@@ -1,319 +1,339 @@
|
|
|
-import {
|
|
|
|
|
- uploadFile
|
|
|
|
|
-} from "../../utils/upload"
|
|
|
|
|
-
|
|
|
|
|
-import {
|
|
|
|
|
- subMsg
|
|
|
|
|
-} from "../../utils/wxUtils"
|
|
|
|
|
-import {
|
|
|
|
|
- postApi
|
|
|
|
|
-} from "../../apis/api"
|
|
|
|
|
|
|
+import { uploadFile } from "../../utils/upload";
|
|
|
|
|
+import { subMsg } from "../../utils/wxUtils";
|
|
|
|
|
+import { postApi } from "../../apis/api";
|
|
|
Page({
|
|
Page({
|
|
|
data: {
|
|
data: {
|
|
|
- avatar: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/avatar-icon.jpg?sign=f5c66c94d189436f82353eb48cb01f08&t=1634538864",
|
|
|
|
|
- cameraIcon: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera-icon.png?sign=11a65871a2800cd04ecaa8991687fccd&t=1634607415",
|
|
|
|
|
- newCameraIcon: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera.png?sign=ad0fe8bead6a46cb20f45f792d4bed67&t=1645502416",
|
|
|
|
|
|
|
+ sign: "https://frontend-1255802371.cos.ap-shanghai.myqcloud.com/sign.png",
|
|
|
|
|
+ avater_exp:
|
|
|
|
|
+ "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/avatar-icon.jpg?sign=f5c66c94d189436f82353eb48cb01f08&t=1634538864",
|
|
|
|
|
+ cameraIcon:
|
|
|
|
|
+ "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera-icon.png?sign=11a65871a2800cd04ecaa8991687fccd&t=1634607415",
|
|
|
|
|
+ newCameraIcon:
|
|
|
|
|
+ "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera.png?sign=ad0fe8bead6a46cb20f45f792d4bed67&t=1645502416",
|
|
|
userName: "",
|
|
userName: "",
|
|
|
phone: "",
|
|
phone: "",
|
|
|
shipName: "",
|
|
shipName: "",
|
|
|
shipMmsi: "",
|
|
shipMmsi: "",
|
|
|
authModal: false,
|
|
authModal: false,
|
|
|
modalText: "位置",
|
|
modalText: "位置",
|
|
|
- shipId: '',
|
|
|
|
|
- locked: false
|
|
|
|
|
|
|
+ shipId: "",
|
|
|
|
|
+ locked: false,
|
|
|
},
|
|
},
|
|
|
openSetting() {
|
|
openSetting() {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
authModal: false,
|
|
authModal: false,
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
wx.openSetting({
|
|
wx.openSetting({
|
|
|
- complete: e => {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
|
|
+ complete: (e) => {
|
|
|
|
|
+ console.log(e);
|
|
|
if (e.authSetting["scope.writePhotosAlbum"]) {
|
|
if (e.authSetting["scope.writePhotosAlbum"]) {
|
|
|
- if (wx.getStorageSync('cacheImage')) {
|
|
|
|
|
|
|
+ if (wx.getStorageSync("cacheImage")) {
|
|
|
wx.saveImageToPhotosAlbum({
|
|
wx.saveImageToPhotosAlbum({
|
|
|
- filePath: wx.getStorageSync('cacheImage'),
|
|
|
|
|
- success: e => {
|
|
|
|
|
|
|
+ filePath: wx.getStorageSync("cacheImage"),
|
|
|
|
|
+ success: (e) => {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: '保存成功!',
|
|
|
|
|
- })
|
|
|
|
|
- wx.removeStorageSync('cacheImage')
|
|
|
|
|
|
|
+ title: "保存成功!",
|
|
|
|
|
+ });
|
|
|
|
|
+ wx.removeStorageSync("cacheImage");
|
|
|
|
|
+ },
|
|
|
|
|
+ complete: (e) => {
|
|
|
|
|
+ console.log(e);
|
|
|
},
|
|
},
|
|
|
- complete: e => {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
takeBill() {
|
|
takeBill() {
|
|
|
- if (this.data.locked) return
|
|
|
|
|
|
|
+ if (this.data.locked) return;
|
|
|
wx.redirectTo({
|
|
wx.redirectTo({
|
|
|
- url: '/pages/takeBill/takeBill',
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ url: "/pages/takeBill/takeBill",
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
async registerShip() {
|
|
async registerShip() {
|
|
|
- if (!this.checkout()) return
|
|
|
|
|
- let res = await postApi('/user/wx/register', {
|
|
|
|
|
- userId: wx.getStorageSync('userId'),
|
|
|
|
|
|
|
+ if (!this.checkout()) return;
|
|
|
|
|
+ let res = await postApi("/user/wx/register", {
|
|
|
|
|
+ userId: wx.getStorageSync("userId"),
|
|
|
shipName: this.data.shipName,
|
|
shipName: this.data.shipName,
|
|
|
shipMmsi: this.data.shipMmsi,
|
|
shipMmsi: this.data.shipMmsi,
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
if (res.data.status == 0) {
|
|
if (res.data.status == 0) {
|
|
|
- let {
|
|
|
|
|
- shipInfo,
|
|
|
|
|
- userInfo
|
|
|
|
|
- } = res.data.result
|
|
|
|
|
|
|
+ let { shipInfo, userInfo } = res.data.result;
|
|
|
|
|
|
|
|
let data = {
|
|
let data = {
|
|
|
...shipInfo,
|
|
...shipInfo,
|
|
|
- ...userInfo
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ...userInfo,
|
|
|
|
|
+ };
|
|
|
Object.keys(data).forEach(function (key) {
|
|
Object.keys(data).forEach(function (key) {
|
|
|
- wx.setStorageSync(key, data[key])
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ wx.setStorageSync(key, data[key]);
|
|
|
|
|
+ });
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
title: res.data.msg,
|
|
title: res.data.msg,
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
this.setData({
|
|
this.setData({
|
|
|
- ...data
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ ...data,
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
title: res.data.msg,
|
|
title: res.data.msg,
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
checkout() {
|
|
checkout() {
|
|
|
if (!this.data.shipName) {
|
|
if (!this.data.shipName) {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: '请输入船名!',
|
|
|
|
|
- icon: "error"
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ title: "请输入船名!",
|
|
|
|
|
+ icon: "error",
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!this.data.shipMmsi) {
|
|
if (!this.data.shipMmsi) {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: '请输入MMSI!',
|
|
|
|
|
- icon: "error"
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ title: "请输入MMSI!",
|
|
|
|
|
+ icon: "error",
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return true
|
|
|
|
|
|
|
+ return true;
|
|
|
},
|
|
},
|
|
|
async takePhoto(e) {
|
|
async takePhoto(e) {
|
|
|
if (this.data.locked) {
|
|
if (this.data.locked) {
|
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
|
- title: '高精度定位中...'
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ title: "高精度定位中...",
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- this.data.locked = true
|
|
|
|
|
- let {
|
|
|
|
|
- mediatype
|
|
|
|
|
- } = e.currentTarget.dataset
|
|
|
|
|
|
|
+ this.data.locked = true;
|
|
|
|
|
+ let { mediatype } = e.currentTarget.dataset;
|
|
|
wx.getLocation({
|
|
wx.getLocation({
|
|
|
- type: 'gcj02',
|
|
|
|
|
|
|
+ type: "gcj02",
|
|
|
isHighAccuracy: true,
|
|
isHighAccuracy: true,
|
|
|
- success: e => {
|
|
|
|
|
- let {
|
|
|
|
|
- latitude,
|
|
|
|
|
- longitude
|
|
|
|
|
- } = e
|
|
|
|
|
- console.log("获取定位成功!", e)
|
|
|
|
|
- this.data.latitude = latitude
|
|
|
|
|
- this.data.longitude = longitude
|
|
|
|
|
- wx.setStorageSync('latitude', latitude)
|
|
|
|
|
- wx.setStorageSync('longitude', longitude)
|
|
|
|
|
|
|
+ success: (e) => {
|
|
|
|
|
+ let { latitude, longitude } = e;
|
|
|
|
|
+ console.log("获取定位成功!", e);
|
|
|
|
|
+ this.data.latitude = latitude;
|
|
|
|
|
+ this.data.longitude = longitude;
|
|
|
|
|
+ wx.setStorageSync("latitude", latitude);
|
|
|
|
|
+ wx.setStorageSync("longitude", longitude);
|
|
|
wx.chooseMedia({
|
|
wx.chooseMedia({
|
|
|
mediaType: ["image"],
|
|
mediaType: ["image"],
|
|
|
sourceType: ["camera"],
|
|
sourceType: ["camera"],
|
|
|
- success: e => {
|
|
|
|
|
- console.log("获取媒体成功!", e)
|
|
|
|
|
- let src = e.tempFiles[0].tempFilePath
|
|
|
|
|
|
|
+ success: (e) => {
|
|
|
|
|
+ console.log("获取媒体成功!", e);
|
|
|
|
|
+ let src = e.tempFiles[0].tempFilePath;
|
|
|
if (e.type == "video") {
|
|
if (e.type == "video") {
|
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
|
- title: '正在压缩...',
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ title: "正在压缩...",
|
|
|
|
|
+ });
|
|
|
wx.compressVideo({
|
|
wx.compressVideo({
|
|
|
src,
|
|
src,
|
|
|
quality: "high",
|
|
quality: "high",
|
|
|
bitrate: "",
|
|
bitrate: "",
|
|
|
fps: "",
|
|
fps: "",
|
|
|
resolution: "",
|
|
resolution: "",
|
|
|
- success: async e => {
|
|
|
|
|
- if (wx.getStorageSync('userName')) {
|
|
|
|
|
|
|
+ success: async (e) => {
|
|
|
|
|
+ if (wx.getStorageSync("userName")) {
|
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
|
- title: '正在上传...',
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ title: "正在上传...",
|
|
|
|
|
+ });
|
|
|
let res = await uploadFile(e.tempFilePath, {
|
|
let res = await uploadFile(e.tempFilePath, {
|
|
|
type: 4,
|
|
type: 4,
|
|
|
- userId: wx.getStorageSync('userId'),
|
|
|
|
|
- location: `${this.data.longitude},${this.data.latitude}`
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ userId: wx.getStorageSync("userId"),
|
|
|
|
|
+ location: `${this.data.longitude},${this.data.latitude}`,
|
|
|
|
|
+ });
|
|
|
if (res.status == 0) {
|
|
if (res.status == 0) {
|
|
|
- console.log(res)
|
|
|
|
|
|
|
+ console.log(res);
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: res.msg
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ title: res.msg,
|
|
|
|
|
+ });
|
|
|
wx.redirectTo({
|
|
wx.redirectTo({
|
|
|
- url: '/pages/takePhoto/success/success',
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ url: "/pages/takePhoto/success/success",
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: res.msg
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ title: res.msg,
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 新用户视频
|
|
// 新用户视频
|
|
|
wx.hideLoading({
|
|
wx.hideLoading({
|
|
|
success: (res) => {},
|
|
success: (res) => {},
|
|
|
- })
|
|
|
|
|
- console.log("新用户视频", e)
|
|
|
|
|
- wx.setStorageSync('type', 2)
|
|
|
|
|
- wx.setStorageSync('file', e.tempFilePath)
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log("新用户视频", e);
|
|
|
|
|
+ wx.setStorageSync("type", 2);
|
|
|
|
|
+ wx.setStorageSync("file", e.tempFilePath);
|
|
|
wx.redirectTo({
|
|
wx.redirectTo({
|
|
|
url: `/pages/newCachePage/newCachePage`,
|
|
url: `/pages/newCachePage/newCachePage`,
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
},
|
|
},
|
|
|
- fail: e => {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ fail: (e) => {
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
wx.compressImage({
|
|
wx.compressImage({
|
|
|
src,
|
|
src,
|
|
|
quality: 80, // 压缩质量
|
|
quality: 80, // 压缩质量
|
|
|
- success: async e => {
|
|
|
|
|
- console.log("图片压缩成功!", e)
|
|
|
|
|
|
|
+ success: async (e) => {
|
|
|
|
|
+ console.log("图片压缩成功!", e);
|
|
|
wx.hideLoading({
|
|
wx.hideLoading({
|
|
|
success: (res) => {},
|
|
success: (res) => {},
|
|
|
- })
|
|
|
|
|
- if (wx.getStorageSync('userName')) {
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ if (wx.getStorageSync("userName")) {
|
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
|
- title: '正在上传...',
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ title: "正在上传...",
|
|
|
|
|
+ });
|
|
|
let postData = {
|
|
let postData = {
|
|
|
type: mediatype,
|
|
type: mediatype,
|
|
|
- userId: wx.getStorageSync('userId'),
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ userId: wx.getStorageSync("userId"),
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
if (mediatype == 3) {
|
|
if (mediatype == 3) {
|
|
|
- postData.location = `${this.data.longitude},${this.data.latitude}`
|
|
|
|
|
|
|
+ postData.location = `${this.data.longitude},${this.data.latitude}`;
|
|
|
} else {
|
|
} else {
|
|
|
- postData.location = ''
|
|
|
|
|
|
|
+ postData.location = "";
|
|
|
}
|
|
}
|
|
|
- let res = await uploadFile(e.tempFilePath, postData)
|
|
|
|
|
- console.log("上传结束", res)
|
|
|
|
|
|
|
+ let res = await uploadFile(e.tempFilePath, postData);
|
|
|
|
|
+ console.log("上传结束", res);
|
|
|
if (res.status == 0) {
|
|
if (res.status == 0) {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: res.msg
|
|
|
|
|
- })
|
|
|
|
|
- wx.setStorageSync('shareImageUrl', res.result.viewUrl)
|
|
|
|
|
- console.log(wx.getStorageSync('shareImageUrl'))
|
|
|
|
|
|
|
+ title: res.msg,
|
|
|
|
|
+ });
|
|
|
|
|
+ wx.setStorageSync("shareImageUrl", res.result.viewUrl);
|
|
|
|
|
+ console.log(wx.getStorageSync("shareImageUrl"));
|
|
|
wx.downloadFile({
|
|
wx.downloadFile({
|
|
|
url: res.result.viewUrl,
|
|
url: res.result.viewUrl,
|
|
|
- success: e => {
|
|
|
|
|
- console.log("下载调用!", e)
|
|
|
|
|
- wx.setStorageSync('cacheImage', e.tempFilePath)
|
|
|
|
|
|
|
+ success: (e) => {
|
|
|
|
|
+ console.log("下载调用!", e);
|
|
|
|
|
+ wx.setStorageSync("cacheImage", e.tempFilePath);
|
|
|
if (mediatype == 3) {
|
|
if (mediatype == 3) {
|
|
|
wx.saveImageToPhotosAlbum({
|
|
wx.saveImageToPhotosAlbum({
|
|
|
filePath: e.tempFilePath,
|
|
filePath: e.tempFilePath,
|
|
|
- success: e => {
|
|
|
|
|
|
|
+ success: (e) => {
|
|
|
if (e.errMsg == "saveImageToPhotosAlbum:ok") {
|
|
if (e.errMsg == "saveImageToPhotosAlbum:ok") {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: '保存成功!',
|
|
|
|
|
- })
|
|
|
|
|
- wx.removeStorageSync('cacheImage')
|
|
|
|
|
|
|
+ title: "保存成功!",
|
|
|
|
|
+ });
|
|
|
|
|
+ wx.removeStorageSync("cacheImage");
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- fail: e => {
|
|
|
|
|
- console.log("失败4", e)
|
|
|
|
|
|
|
+ fail: (e) => {
|
|
|
|
|
+ console.log("失败4", e);
|
|
|
this.setData({
|
|
this.setData({
|
|
|
authModal: true,
|
|
authModal: true,
|
|
|
- modalText: "文件存储"
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ modalText: "文件存储",
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
wx.redirectTo({
|
|
wx.redirectTo({
|
|
|
- url: '/pages/takePhoto/success/success',
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ url: "/pages/takePhoto/success/success",
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
- fail: e => {
|
|
|
|
|
- console.log("失败3", e)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ fail: (e) => {
|
|
|
|
|
+ console.log("失败3", e);
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: res.msg
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ title: res.msg,
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 新用户图片
|
|
// 新用户图片
|
|
|
- console.log("新用户图片", e)
|
|
|
|
|
- wx.setStorageSync('type', 1)
|
|
|
|
|
- wx.setStorageSync('file', e.tempFilePath)
|
|
|
|
|
|
|
+ console.log("新用户图片", e);
|
|
|
|
|
+ wx.setStorageSync("type", 1);
|
|
|
|
|
+ wx.setStorageSync("file", e.tempFilePath);
|
|
|
wx.redirectTo({
|
|
wx.redirectTo({
|
|
|
url: `/pages/newCachePage/newCachePage`,
|
|
url: `/pages/newCachePage/newCachePage`,
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- fail: e => {
|
|
|
|
|
- console.log("失败2", e)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ fail: (e) => {
|
|
|
|
|
+ console.log("失败2", e);
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- fail: e => {
|
|
|
|
|
- console.log("失败1", e)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ fail: (e) => {
|
|
|
|
|
+ console.log("失败1", e);
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
- fail: e => {
|
|
|
|
|
|
|
+ fail: (e) => {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
authModal: true,
|
|
authModal: true,
|
|
|
- modalText: "位置信息"
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ modalText: "位置信息",
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
- complete: e => {
|
|
|
|
|
|
|
+ complete: (e) => {
|
|
|
wx.hideLoading({
|
|
wx.hideLoading({
|
|
|
success: (res) => {},
|
|
success: (res) => {},
|
|
|
- })
|
|
|
|
|
- this.data.locked = false
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ this.data.locked = false;
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
async msg() {
|
|
async msg() {
|
|
|
- let res = await subMsg()
|
|
|
|
|
|
|
+ let res = await subMsg();
|
|
|
|
|
+ },
|
|
|
|
|
+ async checkCheckStatus() {
|
|
|
|
|
+ let { data } = await postApi("/user/wx/checkin/status", {
|
|
|
|
|
+ userId: wx.getStorageSync("userId"),
|
|
|
|
|
+ });
|
|
|
|
|
+ this.setData(data.result);
|
|
|
|
|
+ },
|
|
|
|
|
+ async check() {
|
|
|
|
|
+ if (this.data.checkinStatus == 1) return;
|
|
|
|
|
+ if (this.data.locked) {
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: "高精度定位中...",
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.data.locked = true;
|
|
|
|
|
+ let { mediatype } = e.currentTarget.dataset;
|
|
|
|
|
+ wx.getLocation({
|
|
|
|
|
+ type: "gcj02",
|
|
|
|
|
+ isHighAccuracy: true,
|
|
|
|
|
+ success: async (e) => {
|
|
|
|
|
+ let { latitude, longitude } = e;
|
|
|
|
|
+ let { data } = await postApi("/user/wx/checkin", {
|
|
|
|
|
+ userId: wx.getStorageSync("userId"),
|
|
|
|
|
+ latitude,
|
|
|
|
|
+ longitude,
|
|
|
|
|
+ });
|
|
|
|
|
+ this.setData(data.result);
|
|
|
|
|
+ if (data.status == 0) {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: data.msg,
|
|
|
|
|
+ icon: "success",
|
|
|
|
|
+ duration: 2000,
|
|
|
|
|
+ mask: true,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
onLoad() {
|
|
onLoad() {
|
|
|
- let userName = wx.getStorageSync('userName')
|
|
|
|
|
- let userId = wx.getStorageSync('userId')
|
|
|
|
|
- let phone = wx.getStorageSync('phone')
|
|
|
|
|
- let shipId = wx.getStorageSync('shipId')
|
|
|
|
|
|
|
+ let userName = wx.getStorageSync("userName");
|
|
|
|
|
+ let userId = wx.getStorageSync("userId");
|
|
|
|
|
+ let phone = wx.getStorageSync("phone");
|
|
|
|
|
+ let shipId = wx.getStorageSync("shipId");
|
|
|
|
|
|
|
|
|
|
+ if (userId && shipId) this.checkCheckStatus();
|
|
|
this.setData({
|
|
this.setData({
|
|
|
userName,
|
|
userName,
|
|
|
phone,
|
|
phone,
|
|
|
userId,
|
|
userId,
|
|
|
- shipId
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-})
|
|
|
|
|
|
|
+ shipId,
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+});
|