您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

my-etc-account.vue 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. <FixedFooter>
  53. <button type="default" class="ui-btn" @click="addCompany">
  54. 添加单位账户
  55. </button>
  56. </FixedFooter>
  57. </template>
  58. <script setup lang="ts">
  59. import { reactive, ref } from "vue";
  60. import { onLoad } from "@dcloudio/uni-app";
  61. import { requestNew } from "@/utils/network/request.js";
  62. import { customerQuery, etcChange } from "@/utils/network/api.js";
  63. import { setItem, getItem } from "../../utils/storage";
  64. import { getCredentialType } from "@/datas/credentialType.js";
  65. import { useUserStore } from "@/stores/user";
  66. import FixedFooter from '@/components/common/FixedFooter.vue'
  67. import { objectToQueryString } from '@/utils/utils'
  68. const userStore = useUserStore();
  69. const { saveUserInfo } = userStore;
  70. const state = reactive({
  71. personArr: ref([]),
  72. uniArr: ref([]),
  73. allData: [],
  74. userType: "",
  75. customerId: ""
  76. })
  77. onLoad(() => {
  78. customerQueryInfo()
  79. });
  80. const customerQueryInfo = () => {
  81. const options = {
  82. type: 2,
  83. data: {},
  84. method: "POST",
  85. showLoading: true,
  86. };
  87. //调用方式
  88. requestNew(customerQuery, options)
  89. .then((res) => {
  90. console.log('用户信息', res)
  91. state.allData = res
  92. const customerId = getItem('userInfo') ? getItem('userInfo')['customerId'] : ""
  93. console.log('customerId====111',customerId)
  94. state.customerId = customerId
  95. for (var i = 0; i < res.length; i++) {
  96. // 当前关联某个账户
  97. if (res[i]['customerId'] == customerId) {
  98. res[i]['customerIdChoice'] = true
  99. } else {
  100. res[i]['customerIdChoice'] = false
  101. }
  102. res[i]['idNumStr'] = res[i]['idNum'].replace(/^.{14}/, '**************')
  103. if (res[i]['userType'] == 1) {
  104. state.personArr.push(res[i])
  105. } else {
  106. state.uniArr.push(res[i])
  107. }
  108. }
  109. })
  110. .catch((err) => {
  111. console.log(err);
  112. });
  113. }
  114. const radioChange = (e) => {
  115. console.log("e", e.detail.value)
  116. state.customerId = e.detail.value
  117. let value = e.detail.value
  118. const choiceData = state.allData.filter(item => item.customerId == value);
  119. // 清空对方数组选择
  120. console.log("state.userType", state.userType, choiceData)
  121. console.log("state.personArr", state.personArr, state.uniArr)
  122. uni.showModal({
  123. title: '提示',
  124. content: '确定选择账户',
  125. success: function (res) {
  126. if (res.confirm) {
  127. switchCustomer(choiceData[0])
  128. } else if (res.cancel) {
  129. console.log('用户点击取消');
  130. }
  131. }
  132. });
  133. console.log("choiceData", choiceData)
  134. }
  135. const switchCustomer = (choiceData) => {
  136. requestNew(etcChange, {
  137. data:{customerId: choiceData.customerId}
  138. })
  139. .then((res) => {
  140. console.log('用户信息', res)
  141. let userInfo = getItem('userInfo');
  142. userInfo.customerId = choiceData.customerId;
  143. setItem('customerObj', choiceData);
  144. saveUserInfo(userInfo);
  145. uni.navigateBack()
  146. })
  147. .catch((err) => {
  148. console.log(err);
  149. });
  150. }
  151. // 添加单位账户
  152. const addCompany = () => {
  153. let params = {
  154. isAdd: 1,
  155. addType: 2, // 1: 添加个人用户 2:添加公司用户
  156. }
  157. uni.navigateTo({
  158. url: `/subpackage/personal-center/setting/personal-information/change-user-info?${objectToQueryString(params)}`
  159. })
  160. }
  161. </script>
  162. <style scoped lang="scss">
  163. .content {
  164. padding: 0 30rpx;
  165. .title {
  166. font-size: 28rpx;
  167. color: #666666;
  168. margin: 30rpx 0 20rpx 20rpx;
  169. }
  170. .uni-list {
  171. .item1 {
  172. background: white;
  173. margin-bottom: 20rpx;
  174. display: flex;
  175. border-radius: 20rpx;
  176. padding: 20rpx 0;
  177. display: flex;
  178. align-items: center;
  179. .details {
  180. width: 76%;
  181. margin-left: 26rpx;
  182. .top {
  183. margin-bottom: 6rpx;
  184. .name {
  185. font-size: 30rpx;
  186. color: #01243A;
  187. }
  188. }
  189. }
  190. .img {
  191. width: 80rpx;
  192. height: 80rpx;
  193. }
  194. }
  195. .item {
  196. background: white;
  197. margin-bottom: 20rpx;
  198. display: flex;
  199. border-radius: 20rpx;
  200. padding: 20rpx;
  201. display: flex;
  202. align-items: center;
  203. .details {
  204. width: 76%;
  205. margin-left: 26rpx;
  206. .top {
  207. margin-bottom: 6rpx;
  208. .name {
  209. font-size: 30rpx;
  210. color: #01243A;
  211. }
  212. }
  213. }
  214. .img {
  215. width: 80rpx;
  216. height: 80rpx;
  217. }
  218. }
  219. }
  220. }
  221. .item_father {
  222. background: white !important;
  223. }
  224. .unit-list {
  225. display: flex;
  226. justify-content: space-between;
  227. margin-bottom: 10rpx;
  228. }
  229. .unit-list>text:first-child {
  230. font-size: 24rpx;
  231. color: #888888;
  232. }
  233. .unit-list>text:last-child {
  234. font-size: 26rpx;
  235. color: #444444;
  236. }
  237. .acount {
  238. background: #F9F5EB;
  239. border-radius: 6rpx;
  240. border: 1px solid #CCB375;
  241. font-size: 22rpx;
  242. color: #CCB375;
  243. margin-left: 10rpx;
  244. }
  245. .car {
  246. font-size: 24rpx;
  247. color: #01243A;
  248. }
  249. .danwei {
  250. background: white;
  251. border-radius: 20rpx;
  252. padding: 20rpx;
  253. margin-bottom: 20rpx;
  254. }
  255. </style>