| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- const _Http = getApp().globalData.http;
- const __env = wx.getAccountInfoSync().miniProgram.envVersion;
- const ESIGN_APPID = __env === 'release' ? 'wxa023b292fd19d41d' : 'wx371151823f6f3edf';
- Page({
- data: {
- "id": "2026041315425102",
- list: [],
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 20,
- pageTotal: 1,
- where: {
- condition: ""
- }
- }
- },
- onLoad() {
- this.getList();
- },
- onShow() {
- if (this.data._loaded) {
- this.getList(true);
- }
- this.setData({
- _loaded: true
- });
- },
- /* 获取合同列表 */
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- if (init) {
- this.setData({
- 'content.pageNumber': 1
- });
- }
- if (this.data.content.pageNumber > (this.data.content.pageTotal || 1)) return;
- this.setListHeight();
- _Http.basic({
- id: this.data.id,
- content: this.data.content
- }).then(res => {
- console.log("我的合同列表", res);
- this.selectComponent('#ListBox').RefreshToComplete();
- const statusMap = { '合同创建': '待签署' };
- const list = (res.data || []).map(item => ({
- ...item,
- _status: statusMap[(item.status || '').trim()] || (item.status || '').trim() || this.inferStatus(item)
- }));
- this.setData({
- 'content.pageNumber': res.pageNumber + 1,
- 'content.pageTotal': res.pageTotal,
- list: res.pageNumber == 1 ? list : this.data.list.concat(list),
- total: res.total
- });
- }).catch(err => {
- console.error("获取合同列表失败", err);
- this.selectComponent('#ListBox').RefreshToComplete();
- wx.showToast({
- title: '加载失败',
- icon: 'none'
- });
- });
- },
- /* 设置页面高度 */
- setListHeight() {
- this.selectComponent("#ListBox").setHeight(".header", this);
- },
- /* 推断状态(后端 status 为空时的兜底) */
- inferStatus(item) {
- if (!item.flowid) return '待开始';
- if (item.flowid && !item.downloadurl) return '待签署';
- if (item.downloadurl) return '已签署';
- return '';
- },
- /* 搜索 */
- onSearch({
- detail
- }) {
- this.setData({
- 'content.where.condition': detail
- });
- this.getList(true);
- },
- /* 重新变更确认信息 */
- onReconfirm(e) {
- const item = e.currentTarget.dataset.item;
- wx.showModal({
- title: '温馨提示',
- content: '变更签署信息将作废当前合同并重新创建,之前的签署进度将会丢失,确定继续吗?',
- confirmText: '前去变更',
- cancelText: '取消',
- confirmColor: '#3874F6',
- success: (res) => {
- if (res.confirm) {
- wx.navigateTo({
- url: `/CRM/wmycontract/confirm?id=${item.sa_esign_contract_taskmxid}`
- });
- }
- }
- });
- },
- /* 点击列表项 - 根据状态跳转不同页面 */
- onItemClick(e) {
- const item = e.currentTarget.dataset.item;
- const status = item._status;
- if (status === '待开始') {
- wx.navigateTo({
- url: `/CRM/wmycontract/confirm?id=${item.sa_esign_contract_taskmxid}`
- });
- } else {
- if (item.flowid) {
- wx.navigateToMiniProgram({
- appId: ESIGN_APPID,
- path: `pages/guide?from=app&to=CONTRACT_DETAIL&id=${item.flowid}`,
- envVersion: 'release',
- success(res) {
- console.log('跳转电子签成功', res);
- },
- fail(err) {
- console.error('跳转电子签失败', err);
- }
- });
- } else {
- wx.showToast({
- title: '签署链接暂未生成',
- icon: 'none'
- });
- }
- }
- }
- });
|