You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
169 lines
4.7 KiB
169 lines
4.7 KiB
2 years ago
|
// @ts-nocheck
|
||
|
const app = getApp();
|
||
|
import {
|
||
|
wxGetSetting,
|
||
|
wxShowModal,
|
||
|
wxRequestPost,
|
||
|
wxOpenSetting,
|
||
|
wxAuthorize,
|
||
|
wxStartLocationUpdateBackground
|
||
|
} from "@utils/promise-wx-api";
|
||
|
import getLocation from "@utils/location";
|
||
|
import nextTick from "@npm/dai-mp/tools/nextTick";
|
||
|
|
||
|
Component({
|
||
|
properties: {
|
||
|
titleList: {
|
||
|
type: Array,
|
||
|
value: [],
|
||
|
},
|
||
|
},
|
||
|
|
||
|
data: {
|
||
|
singleComponent: "",
|
||
|
customerTitle: {},
|
||
|
info: {},
|
||
|
},
|
||
|
|
||
|
lifetimes: {
|
||
|
async attached() {
|
||
|
await app.doAfterLogin();
|
||
|
await this.getInfo();
|
||
|
console.log("titleList attached!!!!!");
|
||
|
console.log(app.globalData.customOptions);
|
||
|
console.log(app.globalData.pageCustomerData);
|
||
|
if (
|
||
|
app.globalData.pageCustomerData &&
|
||
|
app.globalData.pageCustomerData.titleList
|
||
|
) {
|
||
|
let componentFrontId =
|
||
|
app.globalData.pageCustomerData.titleList[0].componentFrontId; //this.data.titleList[0].componentFrontId
|
||
|
this.setData({
|
||
|
singleComponent: componentFrontId,
|
||
|
customerTitle: app.globalData.customOptions,
|
||
|
});
|
||
|
}
|
||
|
// await this.startLocation()
|
||
|
},
|
||
|
},
|
||
|
methods: {
|
||
|
async getInfo() {
|
||
|
let customerId = app.globalData.customerId,
|
||
|
gridId = app.globalData.gridId;
|
||
|
const {
|
||
|
data: {
|
||
|
data: { code, data },
|
||
|
},
|
||
|
msg,
|
||
|
} = await wxRequestPost(
|
||
|
"resi/mine/mine/profile",
|
||
|
{
|
||
|
customerId,
|
||
|
gridId,
|
||
|
},
|
||
|
{
|
||
|
// isMock: true,
|
||
|
isQuiet: false,
|
||
|
}
|
||
|
);
|
||
|
console.log("我在titleli加载的");
|
||
|
if (msg === "success" && code === 0) {
|
||
|
console.log("data:", data);
|
||
|
this.setData({
|
||
|
info: data,
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
async startLocation() {
|
||
|
|
||
|
const { volunteerFlag } = this.data.info
|
||
|
console.log('volunteerFlag----info', this.data.info)
|
||
|
if (volunteerFlag == '1') {
|
||
|
// const { msg: msgL, data: dataL } = await getLocation(false);
|
||
|
|
||
|
// if (msgL !== "success") {
|
||
|
// return wx.showToast({
|
||
|
// title: "请允许获取位置权限",
|
||
|
// duration: 2000,
|
||
|
// icon: "none",
|
||
|
// });
|
||
|
// }
|
||
|
console.log('volunteerFlag----', volunteerFlag)
|
||
|
// this.startPatrolMonitor()
|
||
|
}
|
||
|
|
||
|
// wx.startLocationUpdateBackground({
|
||
|
// type: 'gcj02',
|
||
|
// success: r => {
|
||
|
|
||
|
// },
|
||
|
// fali: err => {
|
||
|
// console.log("err------:", err);
|
||
|
// }
|
||
|
// })
|
||
|
},
|
||
|
// async startPatrolMonitor() {
|
||
|
// const { msg: msgA, data: dataA } = await wxAuthorize({
|
||
|
// scope: "scope.userLocationBackground",
|
||
|
// });
|
||
|
// console.log("999999----------------------msgA", msgA);
|
||
|
// console.log("999999----------------------dataA", dataA);
|
||
|
// if (msgA !== "success") {
|
||
|
// const { msg: msgS, data: dataS } = await wxGetSetting();
|
||
|
// if (msgS !== "success") {
|
||
|
// return "";
|
||
|
// }
|
||
|
// if (!dataS.authSetting["scope.userLocationBackground"]) {
|
||
|
// const { msg: msgM, data: dataM } = await wxShowModal({
|
||
|
// title: "请授权获取位置",
|
||
|
// content: "选择“使用小程序期间和离开小程序后”",
|
||
|
// });
|
||
|
// if (msgM !== "success" || dataM.cancel) {
|
||
|
// return console.log("用户取消授权");
|
||
|
// }
|
||
|
// const { msg: msgO, data: dataO } = await wxOpenSetting();
|
||
|
// if (
|
||
|
// msgO !== "success" ||
|
||
|
// !dataS.authSetting["scope.userLocationBackground"]
|
||
|
// ) {
|
||
|
// return;
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// await nextTick(100);
|
||
|
// console.log("---------------实时位置监听start: ");
|
||
|
// const { data } = await wxStartLocationUpdateBackground();
|
||
|
// console.log("---------------实时位置监听start2: ", data);
|
||
|
|
||
|
// wx.onLocationChange((res) => {
|
||
|
// console.log("---------------实时位置监听ing: ", res);
|
||
|
// this.sendLongtude(res);
|
||
|
// });
|
||
|
// },
|
||
|
async sendLongtude(res) {
|
||
|
const params = {
|
||
|
latitude: res.latitude,
|
||
|
longitude: res.longitude,
|
||
|
}
|
||
|
const {
|
||
|
data: {
|
||
|
data: { code, data },
|
||
|
},
|
||
|
msg,
|
||
|
} = await wxRequestPost(
|
||
|
"epmetuser/icVolunteerPoly/LonAndLat",
|
||
|
params,
|
||
|
{
|
||
|
// isMock: true,
|
||
|
isQuiet: false,
|
||
|
}
|
||
|
);
|
||
|
console.log("我在titleli加载的");
|
||
|
if (msg === "success" && code === 0) {
|
||
|
console.log("data:", data);
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
});
|