選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

my-etc-account.vue 6.2KB

1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="content">
  3. <view class="title" v-if="state.personArr.length>0">您名下个人ETC账户</view>
  4. <radio-group class="uni-list" @change="radioChange">
  5. <label class="item" v-for="(item,index) in state.personArr" :key="item.customerId">
  6. <image class="img" :src="`${$imgUrl}myImage/personimg.png`" mode=""></image>
  7. <view class="details">
  8. <view class="top">
  9. <text class="name">{{item.userName}}</text>
  10. <text class="acount" v-if="item.customerIdChoice">当前绑定账户</text>
  11. </view>
  12. <view class="car">{{item.vehicleCount?item.vehicleCount:'无'}}辆车</view>
  13. </view>
  14. <radio :id="item.customerId" :value="item.customerId" :checked="item.customerId==state.customerId"
  15. style="scale: 0.8;"></radio>
  16. </label>
  17. </radio-group>
  18. <view class="title" v-if="state.uniArr.length>0">您名下单位ETC账户</view>
  19. <radio-group class="uni-list" @change="radioChange">
  20. <label class="item_father" v-for="(item,index) in state.uniArr" :key="item.customerId">
  21. <view class="danwei">
  22. <view class="item1">
  23. <image class="img" :src="`${$imgUrl}myImage/unit.png`" mode=""></image>
  24. <view class="details">
  25. <view class="top">
  26. <text class="name">{{item.userName}}</text>
  27. </view>
  28. <view>
  29. <text class="car">{{item.vehicleCount?item.vehicleCount:'无'}}车辆</text>
  30. <text class="acount" v-if="item.customerIdChoice">当前绑定账户</text>
  31. </view>
  32. </view>
  33. <radio :id="item.customerId" :value="item.customerId"
  34. :checked="item.customerId==state.customerId" style="scale: 0.8;"></radio>
  35. </view>
  36. <view class="unit-list">
  37. <text>证件类型</text>
  38. <text>{{getCredentialType(item.idType)}}</text>
  39. </view>
  40. <view class="unit-list">
  41. <text>证件号码</text>
  42. <text>{{item.idNumStr}}</text>
  43. </view>
  44. <view class="unit-list">
  45. <text>分支机构</text>
  46. <text>{{item.department}}</text>
  47. </view>
  48. </view>
  49. </label>
  50. </radio-group>
  51. </view>
  52. </template>
  53. <script setup lang="ts">
  54. import { reactive, ref } from "vue";
  55. import { onLoad } from "@dcloudio/uni-app";
  56. import { requestNew } from "@/utils/network/request.js";
  57. import { customerQuery, etcChange } from "@/utils/network/api.js";
  58. import { setItem, getItem } from "../../utils/storage";
  59. import {
  60. getCredentialType
  61. } from "@/datas/credentialType.js";
  62. import { useUserStore } from "@/stores/user";
  63. const userStore = useUserStore();
  64. const { saveUserInfo } = userStore;
  65. const state = reactive({
  66. personArr: ref([]),
  67. uniArr: ref([]),
  68. allData: [],
  69. userType: "",
  70. customerId: ""
  71. })
  72. onLoad(() => {
  73. customerQueryInfo()
  74. });
  75. const customerQueryInfo = () => {
  76. const options = {
  77. type: 2,
  78. data: {},
  79. method: "POST",
  80. showLoading: true,
  81. };
  82. //调用方式
  83. requestNew(customerQuery, options)
  84. .then((res) => {
  85. console.log('用户信息', res)
  86. state.allData = res
  87. const customerId = getItem('userInfo') ? getItem('userInfo')['customerId'] : ""
  88. console.log('customerId====111',customerId)
  89. state.customerId = customerId
  90. for (var i = 0; i < res.length; i++) {
  91. // 当前关联某个账户
  92. if (res[i]['customerId'] == customerId) {
  93. res[i]['customerIdChoice'] = true
  94. } else {
  95. res[i]['customerIdChoice'] = false
  96. }
  97. res[i]['idNumStr'] = res[i]['idNum'].replace(/^.{14}/, '**************')
  98. if (res[i]['userType'] == 1) {
  99. state.personArr.push(res[i])
  100. } else {
  101. state.uniArr.push(res[i])
  102. }
  103. }
  104. })
  105. .catch((err) => {
  106. console.log(err);
  107. });
  108. }
  109. const radioChange = (e) => {
  110. console.log("e", e.detail.value)
  111. state.customerId = e.detail.value
  112. let value = e.detail.value
  113. const choiceData = state.allData.filter(item => item.customerId == value);
  114. // 清空对方数组选择
  115. console.log("state.userType", state.userType, choiceData)
  116. console.log("state.personArr", state.personArr, state.uniArr)
  117. uni.showModal({
  118. title: '提示',
  119. content: '确定选择账户',
  120. success: function (res) {
  121. if (res.confirm) {
  122. switchCustomer(choiceData[0])
  123. } else if (res.cancel) {
  124. console.log('用户点击取消');
  125. }
  126. }
  127. });
  128. console.log("choiceData", choiceData)
  129. }
  130. const switchCustomer = (choiceData) => {
  131. requestNew(etcChange, {
  132. data:{customerId: choiceData.customerId}
  133. })
  134. .then((res) => {
  135. console.log('用户信息', res)
  136. let userInfo = getItem('userInfo');
  137. userInfo.customerId = choiceData.customerId;
  138. setItem('customerObj', choiceData);
  139. saveUserInfo(userInfo);
  140. uni.navigateBack()
  141. })
  142. .catch((err) => {
  143. console.log(err);
  144. });
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .content {
  149. padding: 0 30rpx;
  150. .title {
  151. font-size: 28rpx;
  152. color: #666666;
  153. margin: 30rpx 0 20rpx 20rpx;
  154. }
  155. .uni-list {
  156. .item1 {
  157. background: white;
  158. margin-bottom: 20rpx;
  159. display: flex;
  160. border-radius: 20rpx;
  161. padding: 20rpx 0;
  162. display: flex;
  163. align-items: center;
  164. .details {
  165. width: 76%;
  166. margin-left: 26rpx;
  167. .top {
  168. margin-bottom: 6rpx;
  169. .name {
  170. font-size: 30rpx;
  171. color: #01243A;
  172. }
  173. }
  174. }
  175. .img {
  176. width: 80rpx;
  177. height: 80rpx;
  178. }
  179. }
  180. .item {
  181. background: white;
  182. margin-bottom: 20rpx;
  183. display: flex;
  184. border-radius: 20rpx;
  185. padding: 20rpx;
  186. display: flex;
  187. align-items: center;
  188. .details {
  189. width: 76%;
  190. margin-left: 26rpx;
  191. .top {
  192. margin-bottom: 6rpx;
  193. .name {
  194. font-size: 30rpx;
  195. color: #01243A;
  196. }
  197. }
  198. }
  199. .img {
  200. width: 80rpx;
  201. height: 80rpx;
  202. }
  203. }
  204. }
  205. }
  206. .item_father {
  207. background: white !important;
  208. }
  209. .unit-list {
  210. display: flex;
  211. justify-content: space-between;
  212. margin-bottom: 10rpx;
  213. }
  214. .unit-list>text:first-child {
  215. font-size: 24rpx;
  216. color: #888888;
  217. }
  218. .unit-list>text:last-child {
  219. font-size: 26rpx;
  220. color: #444444;
  221. }
  222. .acount {
  223. background: #F9F5EB;
  224. border-radius: 6rpx;
  225. border: 1px solid #CCB375;
  226. font-size: 22rpx;
  227. color: #CCB375;
  228. margin-left: 10rpx;
  229. }
  230. .car {
  231. font-size: 24rpx;
  232. color: #01243A;
  233. }
  234. .danwei {
  235. background: white;
  236. border-radius: 20rpx;
  237. padding: 20rpx;
  238. margin-bottom: 20rpx;
  239. }
  240. </style>