请选择 进入手机版 | 继续访问电脑版
MSIPO技术圈 首页 IT技术 查看内容

微信小程序<wxs 使用

2023-07-13

在这里插入图片描述

<wxs module="getOrderStatus" src="./order.wxs"></wxs>

        <view class="flex-shrink0 item-status orderstatus-text {{getOrderStatus.status(globalData, item.state.code, item.allocType.code, item.userId, item.allocUserId, item.canModifyAlloc)}}">
          <text wx:if="{{item.isStop}}">暂停中-{{item.state.name}}</text>
          <text wx:else>{{item.state.name}}</text>
        </view>

order.wxs

// globalData.identity 需求方-1、服务方-2
// code 工单状态 报修审核中-1  报修审核不通过-2  待接单-3  已拒绝-4  服务商已拒绝-5  服务商派单中-6  运维人员拒绝-7  已接单-8  维保中-9  待验收-10  验收不通过-11  待评价-12  已完成-13  待分配-16  已关闭-50  已取消-51

function idInclude(str, id) {
  if (!str) return false
  return str.toString().split(',').indexOf(id + '') > -1
}

var classInfo = 'order-info', classDanger = 'order-danger', classSuccess = 'order-success', classWarning = 'order-warning'
var status = function (globalData, code, allocType, userId, allocUserId, canModifyAlloc) {
  var staColor = classInfo
  var identity = globalData.identity, myId = globalData.myId, authConfig = globalData.auths
  if (identity === 1) { //需求方
    switch (code) {
      case 1:
        staColor = authConfig.workOrderworkOrderAudit ? classWarning : classSuccess
        break
      case 2:
      case 5:
        staColor = userId == myId ? classWarning : classDanger
        break
      case 10:
      case 12:
        staColor = classWarning
        break
      case 4:
      case 11:
        staColor = classDanger
        break
      case 16:
        // staColor = canModifyAlloc && authConfig.workOrderchangeAlloc ? classWarning : classSuccess
        staColor = classSuccess
        break
      case 3:
      case 6:
      case 8:
      case 9:
        staColor = classSuccess
        break
      case 7:
        staColor = classDanger
        break
      default:
        break
    }
  } else if (identity === 2) { //服务方
    switch (code) {
      case 2:
        staColor = classDanger
        break
      case 3:
        staColor = classSuccess
        break
      case 5:
        staColor = classDanger
        break
      case 6:
      case 9:
      case 11:
        // staColor = idInclude(allocUserId, myId) ? classWarning : classSuccess
        staColor = classDanger
        break
      case 7:
        // staColor = authConfig.workOrderworkOrderReceiveAudit ? classWarning : classDanger
        staColor = classDanger
        break
      case 1:
      case 8:
        staColor = classWarning
        break
      case 10:
      case 12:
        staColor = classSuccess
        break
      case 16:
        staColor = canModifyAlloc && authConfig.workOrderchangeAlloc ? classWarning : classSuccess
        break
      default:
        break
    }
  }
  return staColor
}
module.exports = {
  status: status
}

app.wxss

page {
  font-size: 28rpx;
  color: #191919;
  background-color: #f5f5f5;
  /* 定义全局样式变量 */
  --main-font-size: 28rpx;
  --main-color: #409eff;
  --main-bgcolor: #f5f5f5;
  --text-primary: var(--main-color);
  --text-success: #11AF2B;
  --text-warning: #ffab03;
  --text-danger: #e86359;
}
/* 工单状态样式 -start */
.orderstatus-text.order-success {
  color: var(--text-success) !important;
}

.orderstatus-text.order-warning {
  color: var(--text-warning) !important;
}

.orderstatus-text.order-danger {
  color: var(--text-danger) !important;
}

.orderstatus-text.order-info {
  color: #999999 !important;
}

.orderstatus-bg.order-success {
  background-color: var(--text-success) !important;
}

.orderstatus-bg.order-warning {
  background-color: var(--text-warning) !important;
}

.orderstatus-bg.order-danger {
  background-color: var(--text-danger) !important;
}

.orderstatus-bg.order-info {
  background-color: #999999 !important;
}

/* 工单状态样式 -end */

相关阅读

热门文章

    手机版|MSIPO技术圈 皖ICP备19022944号-2

    Copyright © 2024, msipo.com

    返回顶部