日照项目的居民端小程序
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.
 
 
 

535 lines
24 KiB

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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 tools_1 = require("../../../../../utils/tools");
var promise_wx_api_1 = require("../../../../../utils/promise-wx-api");
var index_js_1 = require("../../../../../utils/validate/index.js");
var words_1 = require("../../../../../config/words");
var app = getApp();
Component({
properties: {
badgeId: {
type: String,
value: "",
},
},
data: {
iniLoaded: false,
isApplied: false,
fmData: {
surname: "",
name: "",
idcard: "",
isCertificated: false,
mobile: "",
code: "",
certificationImg: "",
remark: "",
authResult: "",
authReason: "",
recordId: "",
},
fmConfig: {
surname: false,
name: false,
idcard: false,
isCertificated: false,
mobile: false,
code: false,
certificationImg: false,
remark: false,
},
submitBtnIsAllowed: false,
imgList: [],
codeData: {
status: 0,
cd: 0,
},
},
methods: {
onLoad: function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, app.doAfterLogin()];
case 1:
_a.sent();
return [4, this.getFmConfig()];
case 2:
_a.sent();
return [4, this.iniVisit()];
case 3:
_a.sent();
this.setData({
iniLoaded: true,
});
return [2];
}
});
});
},
onShow: function () { },
inputSync: tools_1.inputSync,
$afterUpdateData: function () {
this.computeSubmitBtnIsAllowed();
},
getTelCode: function () {
return __awaiter(this, void 0, void 0, function () {
var codeData, fmData, vlt, _a, code, msg;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
codeData = this.data.codeData;
if (codeData.status == 1 || codeData.cd != 0)
return [2];
fmData = this.data.fmData, vlt = index_js_1.default(fmData, {
mobile: [
{
rule: "required",
message: "请先输入【手机号码】",
},
{
rule: "mobile",
message: "【手机号码】格式不正确",
},
],
});
if (!vlt.valid) {
return [2, wx.showToast({
title: vlt.error,
icon: "none",
duration: 1500,
})];
}
codeData.status = 1;
this.setData({ codeData: codeData });
return [4, promise_wx_api_1.wxRequestPost("epmetuser/more/badge/badgesendcode", {
mobile: fmData.mobile,
}, {
isQuiet: false,
})];
case 1:
_a = _b.sent(), code = _a.data.data.code, msg = _a.msg;
if (msg === "success" && code === 0) {
codeData.status = 2;
codeData.cd = 59;
this.setData({ codeData: codeData });
this.sendTelCodeCd();
}
else {
codeData.status = 3;
this.setData({ codeData: codeData });
}
return [2];
}
});
});
},
sendTelCodeCd: function () {
var _this = this;
var cdFn = function () { return __awaiter(_this, void 0, void 0, function () {
var codeData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, tools_1.nextTick(1000)];
case 1:
_a.sent();
codeData = this.data.codeData;
if (codeData.cd > 0) {
codeData.cd -= 1;
this.setData({ codeData: codeData });
cdFn();
}
return [2];
}
});
}); };
cdFn();
},
handleLongTapCertificationImg: function () {
return __awaiter(this, void 0, void 0, function () {
var certificationImg, _a, msg, data, tapIndex;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
certificationImg = this.data.fmData.certificationImg;
if (!certificationImg)
return [2];
return [4, promise_wx_api_1.wxShowActionSheet({
itemList: ["删除封面", "查看大图"],
})];
case 1:
_a = _b.sent(), msg = _a.msg, data = _a.data;
if (msg == "success") {
tapIndex = data.tapIndex;
if (tapIndex === 0) {
this.deleteCertificationImg();
}
else if (tapIndex === 1) {
this.previewCertificationImg();
}
}
return [2];
}
});
});
},
previewCertificationImg: function () {
var certificationImg = this.data.fmData.certificationImg;
wx.previewImage({
urls: [certificationImg],
});
},
deleteCertificationImg: function () {
this.setData({
imgList: [],
"fmData.certificationImg": "",
});
},
addImg: function () {
return __awaiter(this, void 0, void 0, function () {
var imgList, _a, msg, data, tempFilePaths, newImgList;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
imgList = this.data.imgList;
return [4, promise_wx_api_1.wxChooseImage({
count: 1,
sizeType: ["compressed"],
})];
case 1:
_a = _b.sent(), msg = _a.msg, data = _a.data;
if (msg === "success") {
tempFilePaths = data.tempFilePaths;
newImgList = tempFilePaths.map(function (tempFilePath) {
return {
tempFilePath: tempFilePath,
src: "",
valid: true,
};
});
this.setData({
imgList: newImgList,
"fmData.certificationImg": tempFilePaths[0],
});
this.computeSubmitBtnIsAllowed();
}
return [2];
}
});
});
},
uploadImgs: function () {
return __awaiter(this, void 0, void 0, function () {
var uploadedImgList, imgsValid, imgsAllUploaded;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.data.imgList.length === 0) {
return [2];
}
wx.showLoading({
title: "上传图片中",
mask: true,
});
return [4, new Promise(function (reslove) { return __awaiter(_this, void 0, void 0, function () {
var imgList, residueNum;
var _this = this;
return __generator(this, function (_a) {
imgList = this.data.imgList, residueNum = imgList.length;
imgList.forEach(function (img, index) { return __awaiter(_this, void 0, void 0, function () {
var _a, data, msg;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!(img.src == "")) return [3, 2];
return [4, promise_wx_api_1.wxUploadFile("oss/file/uploadimg", img.tempFilePath, {})];
case 1:
_a = _b.sent(), data = _a.data.data, msg = _a.msg;
if (msg === "success" && data.code === 0) {
img.src = data.data.url;
img.valid = true;
}
_b.label = 2;
case 2:
imgList[index] = img;
residueNum -= 1;
if (residueNum === 0) {
reslove(imgList);
}
return [2];
}
});
}); });
return [2];
});
}); })];
case 1:
uploadedImgList = _a.sent();
wx.hideLoading();
console.log(uploadedImgList);
this.setData({ imgList: uploadedImgList });
imgsValid = uploadedImgList.every(function (item) { return item.valid; }), imgsAllUploaded = uploadedImgList.every(function (item) { return item.src != ""; });
if (!imgsValid) {
wx.showToast({
title: "图片可能包含非法内容",
icon: "none",
duration: 1500,
});
return [2, Promise.reject()];
}
else if (!imgsAllUploaded) {
wx.showToast({
title: "上传图片出错,请重试",
icon: "none",
duration: 1500,
});
return [2, Promise.reject()];
}
else {
return [2, this.setData({
"fmData.certificationImg": uploadedImgList[0].src,
})];
}
return [2];
}
});
});
},
computeSubmitBtnIsAllowed: function (isQuiet) {
if (isQuiet === void 0) { isQuiet = true; }
var _a = this.data, fmConfig = _a.fmConfig, fmData = _a.fmData;
var fmAllRules = {
surname: [
{
rule: "required",
message: "请先输入您的【姓氏】",
},
],
name: [
{
rule: "required",
message: "请先输入您的【名字】",
},
],
idcard: [
{
rule: "required",
message: "请先输入您的【证件号】",
},
],
mobile: [
{
rule: "required",
message: "请先输入【手机号码】",
},
{
rule: "mobile",
message: "【手机号码】格式不正确",
},
],
code: [
{
rule: "required",
message: "请先输入【短信验证码】",
},
],
remark: [
{
rule: "required",
message: "请先输入【备注】",
},
],
certificationImg: [
{
rule: "required",
message: "请上传【认证证件】",
},
],
};
var fmRules = {};
Object.keys(fmAllRules).forEach(function (k) {
if (fmConfig[k]) {
fmRules[k] = fmAllRules[k];
}
});
var vlt = index_js_1.default(fmData, fmRules);
if (!vlt.valid) {
if (!isQuiet) {
wx.showToast({
title: vlt.error,
icon: "none",
duration: 1500,
});
}
this.setData({
submitBtnIsAllowed: false,
});
return false;
}
else {
this.setData({
submitBtnIsAllowed: true,
});
return true;
}
},
iniVisit: function () {
return __awaiter(this, void 0, void 0, function () {
var customerId, _a, badgeId, fmData, _b, _c, code, data, msg;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
customerId = app.globalData.customerId;
_a = this.data, badgeId = _a.badgeId, fmData = _a.fmData;
return [4, promise_wx_api_1.wxRequestPost("epmetuser/more/badge/certification/detail", {
badgeId: badgeId,
customerId: customerId,
}, {
isQuiet: false,
})];
case 1:
_b = _d.sent(), _c = _b.data.data, code = _c.code, data = _c.data, msg = _b.msg;
if (msg === "success" && code === 0) {
this.setData({
fmData: __assign(__assign({}, fmData), data),
isApplied: true,
});
this.computeSubmitBtnIsAllowed();
}
return [2];
}
});
});
},
getFmConfig: function () {
return __awaiter(this, void 0, void 0, function () {
var customerId, _a, badgeId, fmConfig, _b, _c, code, data, msg;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
customerId = app.globalData.customerId;
_a = this.data, badgeId = _a.badgeId, fmConfig = _a.fmConfig;
return [4, promise_wx_api_1.wxRequestPost("epmetuser/more/badge/authfield", {
badgeId: badgeId,
customerId: customerId,
}, {
isQuiet: false,
})];
case 1:
_b = _d.sent(), _c = _b.data.data, code = _c.code, data = _c.data, msg = _b.msg;
if (msg === "success" && code === 0) {
if (Array.isArray(data) && data.length > 0) {
data.forEach(function (item) {
fmConfig[item.enName] = true;
});
}
if (fmConfig.mobile) {
fmConfig.code = true;
}
this.setData({
fmConfig: fmConfig,
});
}
return [2];
}
});
});
},
submit: function () {
return __awaiter(this, void 0, void 0, function () {
var _a, badgeId, fmData, fmConfig, customerId, reqData, _b, _c, code, data, msg;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
if (!this.computeSubmitBtnIsAllowed(false))
return [2];
return [4, this.uploadImgs()];
case 1:
_d.sent();
_a = this.data, badgeId = _a.badgeId, fmData = _a.fmData, fmConfig = _a.fmConfig;
customerId = app.globalData.customerId;
reqData = {};
Object.keys(fmData).forEach(function (k) {
if (fmConfig[k]) {
reqData[k] = fmData[k];
}
});
wx.showLoading({
title: words_1.default.common.submitting,
mask: true,
});
return [4, promise_wx_api_1.wxRequestPost("resi/mine/badge/certification/add", __assign({ customerId: customerId,
badgeId: badgeId }, reqData), {
isQuiet: false,
})];
case 2:
_b = _d.sent(), _c = _b.data.data, code = _c.code, data = _c.data, msg = _b.msg;
wx.hideLoading();
if (!(msg === "success" && code === 0)) return [3, 5];
return [4, this.selectComponent("#requestMsg").handleMsg()];
case 3:
_d.sent();
promise_wx_api_1.wxShowToast({
title: "提交成功,请等待审核",
duration: 1500,
});
return [4, tools_1.nextTick(1500)];
case 4:
_d.sent();
wx.navigateBack();
_d.label = 5;
case 5: return [2];
}
});
});
},
},
});