index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <ay-container>
  3. <ay-skeletons :rowList="data.rowList" :loading="data.firstLoad">
  4. <div class="center items-start top">
  5. <div v-if="data.orgDetail.driverApply">
  6. <div>加入申请{{ config.common.auditStatus[data.orgDetail.driverApply.auditStatus] }}</div>
  7. <div v-if="data.orgDetail.driverApply.auditStatus === 3" class="b-fz mt-spac">
  8. {{ data.orgDetail.driverApply.resMsg }}
  9. </div>
  10. </div>
  11. <uni-easyinput
  12. suffixIcon="scan"
  13. v-model="data.orgId"
  14. placeholder="请输入物流公司企业识别码"
  15. @iconClick="methods.scan"
  16. class="getorg flex-1"
  17. v-if="showFindOrg"
  18. ></uni-easyinput>
  19. <img :src="topbgimg" class="bgimg" />
  20. </div>
  21. <div v-if="orgInfoSuccess" class="chunk1 bs-fz">
  22. <div>
  23. <image src="@img/icons/org_icon.png" class="mr-spac org-icon" />
  24. <div>{{ data.orgInfo.orgName }}</div>
  25. </div>
  26. <div @click="methods.phone(data.orgInfo.bindPhone)" class="mt-spac p-color">
  27. <uni-icons type="phone" color="" class="mr-spac" size="36"></uni-icons>
  28. <div class="b-fz">{{ data.orgInfo.bindPhone }}</div>
  29. </div>
  30. </div>
  31. <div class="center m-spac">
  32. <template v-if="data.orgDetail.driverApply?.auditStatus === 1">
  33. 若想更快审核通过,可以联系企业联系人
  34. </template>
  35. <div v-if="data.orgDetail.driverApply?.auditStatus === 3" class="text-center">
  36. 如对处理有异议,请联系物流公司处理或拨打平台客服电话:
  37. <span class="p-color" @click="methods.phone(store.common.data.phone)">
  38. <uni-icons type="phone" color="" class="mr-spacd4" size="none"></uni-icons>
  39. <span>{{ store.common.data.phone }}</span>
  40. </span>
  41. </div>
  42. </div>
  43. <div class="btns">
  44. <button
  45. type="primary"
  46. :disabled="!orgInfoSuccess"
  47. v-if="showApply"
  48. @click="methods.enterMsg"
  49. >
  50. {{ btnText }}
  51. </button>
  52. </div>
  53. <uni-popup ref="inputDialog" type="dialog">
  54. <uni-popup-dialog
  55. mode="input"
  56. title="请谨慎操作"
  57. :beforeClose="true"
  58. @confirm="methods.apply"
  59. @close="methods.closePopup"
  60. >
  61. <div class="text-center w-100%">
  62. <div class="mb-spacd2">您将申请{{ hasOrg ? '退出' : '加入' }}该物流公司</div>
  63. <uni-easyinput
  64. type="textarea"
  65. v-model="data.reqMsg"
  66. placeholder="请填写申请理由"
  67. ></uni-easyinput>
  68. </div>
  69. </uni-popup-dialog>
  70. </uni-popup>
  71. </ay-skeletons>
  72. </ay-container>
  73. </template>
  74. <script lang="ts" setup>
  75. import defbg from '@img/controct_bg.png'
  76. import topbg1 from '@img/driver_apply1.png'
  77. import topbg3 from '@img/driver_apply3.png'
  78. const inputDialog = ref()
  79. const data = reactive({
  80. firstLoad: true,
  81. rowList: [
  82. {
  83. align: 'left',
  84. verticalAlign: 'top',
  85. colItems: [
  86. {
  87. style: {
  88. width: '100%',
  89. height: '200px',
  90. },
  91. },
  92. ],
  93. },
  94. ...Array(10).fill({
  95. align: 'left',
  96. colItems: 1,
  97. }),
  98. {
  99. align: 'left',
  100. colItems: [
  101. {
  102. style: {
  103. width: '60%',
  104. },
  105. },
  106. ],
  107. },
  108. ],
  109. orgId: '',
  110. reqMsg: '',
  111. orgInfo: {} as Org对象,
  112. orgDetail: {} as 司机的企业团队信息,
  113. })
  114. /** 头部背景图 */
  115. const topbgimg = computed(() => {
  116. let rv = defbg
  117. if (data.orgDetail.driverApply) {
  118. if (data.orgDetail.driverApply?.auditStatus === 1) {
  119. rv = topbg1
  120. }
  121. if (data.orgDetail.driverApply?.auditStatus === 3) {
  122. rv = topbg3
  123. }
  124. }
  125. return rv
  126. })
  127. /** 有所属物流 */
  128. const hasOrg = computed(() => {
  129. return !!data.orgDetail.org
  130. })
  131. /** 显示申请界面 */
  132. const showApply = computed(() => {
  133. return data.orgDetail.driverApply?.auditStatus === 3 || !data.orgDetail.driverApply
  134. })
  135. /** 显示企业识别码 */
  136. const showFindOrg = computed(() => {
  137. return !data.orgDetail.driverApply && !data.orgDetail.org
  138. })
  139. /** 按钮文案 */
  140. const btnText = computed(() => {
  141. let rv = '申请加入'
  142. if (hasOrg.value) {
  143. rv = '申请退出'
  144. }
  145. if (data.orgDetail.driverApply?.auditStatus === 3) {
  146. rv = '再次申请'
  147. }
  148. return rv
  149. })
  150. /** 物流id验证成功 */
  151. const orgIdVerified = computed(() => data.orgId.length === 18)
  152. /** 物流信息获取成功 */
  153. const orgInfoSuccess = computed(() => orgIdVerified.value && store.webapi.user.find_4.success)
  154. watch(
  155. () => data.orgId,
  156. (nv) => {
  157. if (orgIdVerified.value) {
  158. methods.getOrgInfo()
  159. } else {
  160. data.orgInfo = {}
  161. }
  162. },
  163. )
  164. const methods = {
  165. phone(num) {
  166. uni.makePhoneCall({
  167. phoneNumber: num,
  168. })
  169. },
  170. async scan() {
  171. const rt: { orgId?: string } = await func.native.scan()
  172. if (!rt.orgId) {
  173. func.native.showToast('二维码无效')
  174. return
  175. }
  176. data.orgId = rt.orgId
  177. },
  178. closePopup() {
  179. inputDialog.value.close()
  180. },
  181. getOrgInfo() {
  182. return webapi.user.find_4({ orgId: data.orgId }).then((res) => {
  183. data.orgInfo = res
  184. })
  185. },
  186. enterMsg() {
  187. if (data.orgDetail.driverApply?.auditStatus === 3) {
  188. data.orgDetail.driverApply = null
  189. } else {
  190. inputDialog.value.open()
  191. }
  192. },
  193. apply() {
  194. if (!data.reqMsg) {
  195. func.native.showToast('请输入申请原因')
  196. return
  197. }
  198. if (store.webapi.user.driver_entry.ing) {
  199. return
  200. }
  201. methods.closePopup()
  202. if (hasOrg.value) {
  203. webapi.user.driver_quit({ type: 4, reqMsg: data.reqMsg }).then((res) => {
  204. if (res) {
  205. // 退出成功 服务端身份失效
  206. func.native.showToast('退出成功').then(() => {
  207. store.user.clearUserInfo()
  208. })
  209. } else {
  210. func.native.showToast('退出失败')
  211. }
  212. })
  213. } else {
  214. webapi.user
  215. .driver_entry<{ orgId: string }>({ orgId: data.orgId, reqMsg: data.reqMsg })
  216. .then((res) => {
  217. if (res) {
  218. func.native.showToast('申请成功')
  219. methods.findOrgDetail()
  220. } else {
  221. func.native.showToast('申请失败')
  222. }
  223. })
  224. }
  225. },
  226. async findOrgDetail() {
  227. return webapi.user.find_org_detail({ id: store.user.userInfo.user_id }).then(async (res) => {
  228. data.orgDetail = res
  229. // 已申请 自动查询物流公司信息
  230. if (res.driverApply) {
  231. data.orgId = res.driverApply.orgId
  232. await methods.getOrgInfo()
  233. }
  234. // 司机有所属物流公司
  235. if (hasOrg.value) {
  236. data.orgId = res.org.orgId
  237. await methods.getOrgInfo()
  238. }
  239. if (!res.driverApply || !hasOrg.value) {
  240. store.webapi.user.find_4.set(enums.ReqState.success)
  241. }
  242. })
  243. },
  244. }
  245. ay.entrance(async (args) => {
  246. await methods.findOrgDetail()
  247. data.firstLoad = false
  248. })
  249. </script>
  250. <style lang="scss" scoped>
  251. ::v-deep .uni-popup__info {
  252. @apply: font-bold;
  253. font-size: $bs-fz;
  254. color: unset;
  255. }
  256. ::v-deep .uni-textarea-textarea,
  257. .uni-easyinput__placeholder-class {
  258. font-size: $p-fz;
  259. }
  260. ::v-deep .uni-easyinput__content {
  261. .uni-easyinput__content-input {
  262. height: $p-spac * 3;
  263. font-size: $bs-fz;
  264. }
  265. .uni-easyinput__placeholder-class {
  266. font-size: $bs-fz;
  267. }
  268. .uniui-scan {
  269. font-size: $p-fz * 2 !important;
  270. }
  271. }
  272. .top {
  273. position: relative;
  274. height: 300rpx;
  275. padding: $p-spac;
  276. color: $p-recolor;
  277. & .bgimg {
  278. position: absolute;
  279. top: 0;
  280. left: 0;
  281. z-index: -1;
  282. width: 100%;
  283. }
  284. }
  285. .org-icon {
  286. width: 32px;
  287. height: 32px;
  288. }
  289. </style>