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.
433 lines
15 KiB
433 lines
15 KiB
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
function step(op) {
|
|
if (f) throw new TypeError("Generator is already executing.");
|
|
while (_) try {
|
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
switch (op[0]) {
|
|
case 0: case 1: t = op; break;
|
|
case 4: _.label++; return { value: op[1], done: false };
|
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
default:
|
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
if (t[2]) _.ops.pop();
|
|
_.trys.pop(); continue;
|
|
}
|
|
op = body.call(thisArg, _);
|
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
}
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var config_1 = require("../../../../config/config");
|
|
var QQMapWX = require("../../utils/qqmap-wx-jssdk.js");
|
|
var api = require("../../../../utils/api");
|
|
var promise_wx_api_1 = require("../../../../utils/promise-wx-api");
|
|
var tools_1 = require("../../../../utils/tools");
|
|
var app = getApp();
|
|
Page({
|
|
data: {
|
|
addlive: false,
|
|
dataUploading: false,
|
|
BASEURL: config_1.config.apiUrl,
|
|
qqmapsdk: "",
|
|
signin: {},
|
|
actId: "",
|
|
operationDesc: "",
|
|
operationDesc_: "",
|
|
locationLongitude: Number,
|
|
locationLatitude: Number,
|
|
operationAddress: "",
|
|
images: [],
|
|
clockType: Number,
|
|
effectiveFlag: Number,
|
|
phraseList: [],
|
|
phraseId: "",
|
|
ldata: false,
|
|
inRange: false,
|
|
live: true,
|
|
act: "",
|
|
},
|
|
onLoad: function (options) {
|
|
var that = this;
|
|
var qqmapsdk = new QQMapWX({
|
|
key: "CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ",
|
|
});
|
|
if (options.currentUserStatus == "4") {
|
|
that.setData({
|
|
clockType: 0,
|
|
});
|
|
}
|
|
else {
|
|
that.setData({
|
|
clockType: 1,
|
|
});
|
|
}
|
|
that.setData({
|
|
qqmapsdk: qqmapsdk,
|
|
act: options.act,
|
|
id: options.id,
|
|
effectiveFlag: 1,
|
|
});
|
|
if (options.act == "sign") {
|
|
wx.setNavigationBarTitle({
|
|
title: "签到打卡",
|
|
});
|
|
}
|
|
else {
|
|
wx.setNavigationBarTitle({
|
|
title: "添加实况",
|
|
});
|
|
}
|
|
that.getPosition();
|
|
},
|
|
onShow: function () {
|
|
},
|
|
checkboxChange: function (e) {
|
|
console.log("checkbox发生change事件,携带value值为:", e.detail.value.length);
|
|
if (e.detail.value.length == 0) {
|
|
this.setData({
|
|
live: false,
|
|
});
|
|
}
|
|
else {
|
|
this.setData({
|
|
live: true,
|
|
});
|
|
}
|
|
},
|
|
isInRange: function (lat, lng) {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var fmData, rst;
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0:
|
|
fmData = {
|
|
longitude: lng,
|
|
latitude: lat,
|
|
actId: this.data.id,
|
|
};
|
|
return [4, promise_wx_api_1.wxRequestPost("heart/resi/act/checksigninaddress", fmData, {
|
|
isMock: false,
|
|
})];
|
|
case 1:
|
|
rst = _a.sent();
|
|
console.log("checksigninaddress", rst.data.data.data);
|
|
console.log("rst.msg", rst.msg);
|
|
if (rst.msg == "success") {
|
|
console.log("rst.data.isAddress", rst.data.data.data.isAddress);
|
|
this.setData({
|
|
inRange: rst.data.data.data.isAddress,
|
|
});
|
|
if (!rst.data.data.data.isAddress) {
|
|
wx.showToast({
|
|
title: "尚未进入签到范围",
|
|
icon: "none",
|
|
duration: 3000,
|
|
});
|
|
}
|
|
}
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
getPosition: function () {
|
|
var _this = this;
|
|
var that = this;
|
|
wx.getLocation({
|
|
type: "gcj02",
|
|
success: function (res) {
|
|
that.reverseGeocoder(res);
|
|
that.setData({
|
|
ldata: false,
|
|
locationLongitude: res.longitude,
|
|
locationLatitude: res.latitude,
|
|
});
|
|
if (_this.data.act == "sign") {
|
|
_this.isInRange(res.latitude, res.longitude);
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
if (res.errMsg === "getLocation:fail auth deny") {
|
|
that.setData({
|
|
ldata: true,
|
|
});
|
|
wx.showToast({
|
|
title: "位置获取失败,请开启手机GPS定位或重新授权获取位置信息",
|
|
icon: "none",
|
|
duration: 3000,
|
|
});
|
|
console.log(res);
|
|
}
|
|
},
|
|
});
|
|
},
|
|
handler: function (e) {
|
|
var that = this;
|
|
if (!e.detail.authSetting["scope.userLocation"]) {
|
|
that.setData({
|
|
ldata: true,
|
|
});
|
|
}
|
|
else {
|
|
that.setData({
|
|
ldata: false,
|
|
});
|
|
wx.getLocation({
|
|
type: "gcj02",
|
|
success: function (res) {
|
|
var latitude = res.latitude;
|
|
var longitude = res.longitude;
|
|
that.setData({
|
|
locationLongitude: longitude,
|
|
locationLatitude: latitude,
|
|
});
|
|
},
|
|
});
|
|
}
|
|
},
|
|
reverseGeocoder: function (_a) {
|
|
var latitude = _a.latitude, longitude = _a.longitude;
|
|
var that = this;
|
|
that.data.qqmapsdk.reverseGeocoder({
|
|
location: {
|
|
latitude: latitude,
|
|
longitude: longitude,
|
|
},
|
|
success: function (res) {
|
|
if (res.message === "query ok") {
|
|
that.setData({
|
|
operationAddress: res.result.address,
|
|
});
|
|
}
|
|
},
|
|
});
|
|
},
|
|
getPhraseList: function () {
|
|
var that = this;
|
|
api.getPhraseList().then(function (res) {
|
|
that.setData({
|
|
phraseList: res.data,
|
|
});
|
|
});
|
|
},
|
|
toOperationDesc: function (phrase) {
|
|
this.setData({
|
|
operationDesc: this.data.operationDesc + phrase.currentTarget.dataset.phrase,
|
|
phraseId: phrase.currentTarget.dataset.id,
|
|
});
|
|
},
|
|
onChange: function (e) {
|
|
var file = e.detail.file;
|
|
if (file.status === "uploading") {
|
|
this.setData({
|
|
progress: 0,
|
|
});
|
|
wx.showLoading();
|
|
}
|
|
else if (file.status === "done") {
|
|
this.setData({
|
|
imageUrl: file.url,
|
|
});
|
|
}
|
|
console.log(e);
|
|
var images = [];
|
|
e.detail.fileList.forEach(function (item, index) {
|
|
if (item.res !== undefined) {
|
|
var imageUrl = JSON.parse(e.detail.fileList[index].res.data).data.url;
|
|
images.push(imageUrl);
|
|
}
|
|
});
|
|
this.setData({
|
|
images: images,
|
|
});
|
|
},
|
|
onComplete: function () {
|
|
wx.hideLoading();
|
|
},
|
|
onPreview: function (e) {
|
|
var _a = e.detail, file = _a.file, fileList = _a.fileList;
|
|
wx.previewImage({
|
|
current: file.url,
|
|
urls: fileList.map(function (n) { return n.url; }),
|
|
});
|
|
},
|
|
getbindinput: function (e) {
|
|
this.setData({
|
|
operationDesc: e.detail.value,
|
|
});
|
|
},
|
|
submission: function () {
|
|
if (this.data.live) {
|
|
if (this.data.operationDesc === "" && this.data.images.length == 0) {
|
|
wx.showToast({
|
|
title: "请填写打卡描述或上传实况图片",
|
|
icon: "none",
|
|
duration: 3000,
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
if (this.data.dataUploading) {
|
|
wx.showToast({
|
|
title: "正在提交",
|
|
icon: "none",
|
|
duration: 3000,
|
|
});
|
|
return false;
|
|
}
|
|
this.setData({
|
|
dataUploading: true,
|
|
});
|
|
var signinLongitude = this.data.signin.signinLongitude;
|
|
var signinLatitude = this.data.signin.signinLatitude;
|
|
var clockLongitudeMy = 0;
|
|
var clockLatitudeMy = 0;
|
|
var params = {
|
|
actId: this.data.id,
|
|
desc: this.data.operationDesc,
|
|
longitude: this.data.locationLongitude,
|
|
latitude: this.data.locationLatitude,
|
|
address: this.data.operationAddress,
|
|
images: this.data.images,
|
|
syncLive: this.data.live ? 1 : 0,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
var that = this;
|
|
api
|
|
.clock(params)
|
|
.then(function (res) {
|
|
that.setData({
|
|
dataUploading: false,
|
|
});
|
|
if (res.code == 0) {
|
|
wx.showToast({
|
|
title: "签到打卡成功",
|
|
icon: "none",
|
|
duration: 3000,
|
|
complete: function () {
|
|
setTimeout(function () {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
});
|
|
}, 1000);
|
|
},
|
|
});
|
|
}
|
|
})
|
|
.catch(function (err) {
|
|
that.setData({
|
|
dataUploading: false,
|
|
});
|
|
});
|
|
},
|
|
newlive: function () {
|
|
if (this.data.live) {
|
|
if (this.data.operationDesc === "" && this.data.images.length == 0) {
|
|
wx.showToast({
|
|
title: "请填写打卡描述或上传实况图片",
|
|
icon: "none",
|
|
duration: 3000,
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
if (this.data.addlive) {
|
|
wx.showToast({
|
|
title: "正在提交",
|
|
icon: "none",
|
|
duration: 3000,
|
|
});
|
|
return false;
|
|
}
|
|
this.setData({
|
|
addlive: true,
|
|
});
|
|
var params = {
|
|
actId: this.data.id,
|
|
desc: this.data.operationDesc,
|
|
longitude: this.data.locationLongitude,
|
|
latitude: this.data.locationLatitude,
|
|
address: this.data.operationAddress,
|
|
images: this.data.images,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
var that = this;
|
|
api.newlive(params).then(function (res) {
|
|
if (res.code == 0) {
|
|
that.setData({
|
|
operationDesc: "",
|
|
images: [],
|
|
fileList: [],
|
|
});
|
|
wx.showToast({
|
|
title: "添加实况成功",
|
|
icon: "none",
|
|
mask: true,
|
|
duration: 3000,
|
|
complete: function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var pages, prevPage;
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0: return [4, tools_1.nextTick(1500)];
|
|
case 1:
|
|
_a.sent();
|
|
pages = getCurrentPages();
|
|
prevPage = pages[pages.length - 2];
|
|
prevPage.setData({
|
|
curtab: "live",
|
|
});
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
});
|
|
that.setData({
|
|
addlive: false,
|
|
});
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
});
|
|
}
|
|
else {
|
|
that.setData({
|
|
addlive: false,
|
|
});
|
|
}
|
|
});
|
|
},
|
|
Rad: function (d) {
|
|
return (d * Math.PI) / 180.0;
|
|
},
|
|
clockAddressDetail: function () {
|
|
var that = this;
|
|
var id = that.data.id;
|
|
api.clockAddressDetail(id).then(function (res) {
|
|
if (res.code == 0) {
|
|
that.setData({
|
|
signin: res.data,
|
|
});
|
|
}
|
|
});
|
|
},
|
|
});
|
|
|