You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

choice-order.vue 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="selectCar-box">
  3. <view v-if="state.list&&state.list.length>0" @click="choose(i,item)" class="item" v-for="(item,i) in state.list"
  4. :key="i">
  5. <view class="iten-left">
  6. <view>新办单号:{{item.orderId}}</view>
  7. <view>订单车牌号:{{item.vehiclePlate}}</view>
  8. <view>订单车牌颜色:{{getVehiclePlateColor(item.vehiclePlateColor)}}</view>
  9. </view>
  10. <view class="choose-item">
  11. <view class="active" v-if="flag==i">
  12. </view>
  13. </view>
  14. </view>
  15. <view v-else>
  16. <empty title='暂无找到相关订单信息' />
  17. </view>
  18. </view>
  19. </template>
  20. <script lang="ts" setup>
  21. import empty from "@/components/empty/empty.vue";
  22. import {
  23. reactive,
  24. ref
  25. } from "vue"
  26. import {
  27. msg,
  28. navTo
  29. } from "@/utils/utils"
  30. import {
  31. onLoad,
  32. } from "@dcloudio/uni-app";
  33. import {
  34. orderList, addEquityListApi
  35. } from "@/utils/network/api.js";
  36. import {
  37. request
  38. } from "@/utils/network/request.js";
  39. import {
  40. getItem,
  41. StorageKeys,
  42. } from "@/utils/storage";
  43. import {
  44. stringToJson
  45. } from "@/utils/network/encryption";
  46. import {
  47. vehiclePlateColor
  48. } from "@/datas/vehiclePlateColor";
  49. const state = reactive({
  50. list: [],//车辆list,
  51. equtyId: "",//权益id
  52. });
  53. const flag = ref('0') //默认选择0
  54. //获取车牌颜色文字
  55. const getVehiclePlateColor = (id : number) => {
  56. const colors = vehiclePlateColor.filter(item => item.id == id);
  57. return colors[0].color
  58. }
  59. onLoad((option) => {
  60. state.equtyId = option.equtyId
  61. quanCheckActionTrue().then((item : any) => {
  62. console.log("1", item.data)
  63. state.list = item.data
  64. })
  65. });
  66. const quanCheckActionTrue = () => {
  67. let source = ""
  68. // #ifdef MP-ALIPAY
  69. source = "ALI"
  70. // #endif
  71. // #ifdef MP-WEIXIN
  72. source = "WECHAT"
  73. // #endif
  74. var data = {
  75. "opId": getItem(StorageKeys.OpenId),
  76. "source": source,
  77. "vehiclePlate": "",
  78. "tabIndex": "0",
  79. "pageNo": 1,
  80. "pageSize": 1000,
  81. "promotionModes": 1,
  82. "isAfter": true,
  83. "orderStatus": 1
  84. };
  85. const options = {
  86. type: 2,
  87. data: data,
  88. method: "POST",
  89. showLoading: true,
  90. };
  91. return new Promise(async (resolve, reject) => {
  92. const res = await request(orderList, options);
  93. const data = stringToJson(res.bizContent);
  94. resolve(data);
  95. }).catch((error) => {
  96. reject(error);
  97. });
  98. }
  99. const choose = (i, item) => {
  100. console.log("item", item)
  101. flag.value = i
  102. const options = {
  103. type: 2,
  104. data: {
  105. "type": 1,
  106. "openId": getItem(StorageKeys.OpenId),
  107. "orderId": item.orderId,
  108. "equityId": state.equtyId
  109. },
  110. method: 'POST',
  111. showLoading: true,
  112. }
  113. // 权益购买入参有个属性是type:1,代表查询是否已经买过了权益,返回的数据中hasData:true表示买过了,如果hasData:false表示没买过。type:2,表示购买
  114. request(addEquityListApi, options).then((res) => {
  115. const data = stringToJson(res.bizContent);
  116. console.log("加购", data.hasData)
  117. if (data.hasData) {
  118. uni.showModal({
  119. title: '提示',
  120. content: '重复购买此产品',
  121. success: function (res) {
  122. if (res.confirm) {
  123. console.log('用户点击确定');
  124. chooseBuy(item)
  125. } else if (res.cancel) {
  126. console.log('用户点击取消');
  127. }
  128. }
  129. });
  130. } else {
  131. chooseBuy(item)
  132. }
  133. })
  134. }
  135. const chooseBuy = (item) => {
  136. console.log("item", item)
  137. const options = {
  138. type: 2,
  139. data: {
  140. "type": 2,
  141. "openId": getItem(StorageKeys.OpenId),
  142. "orderId": item.orderId,
  143. "equityId": state.equtyId
  144. },
  145. method: 'POST',
  146. showLoading: true,
  147. }
  148. // 权益购买入参有个属性是type:1,代表查询是否已经买过了权益,返回的数据中hasData:true表示买过了,如果hasData:false表示没买过。type:2,表示购买
  149. request(addEquityListApi, options).then((res) => {
  150. const data = stringToJson(res.bizContent);
  151. console.log("购买2", data)
  152. msg("购买成功")
  153. setTimeout(() => {
  154. uni.navigateBack({
  155. delta: 2
  156. })
  157. }, 2000)
  158. })
  159. }
  160. </script>
  161. <style>
  162. page {
  163. width: 100%;
  164. height: 100%;
  165. background-color: #EEF7F7;
  166. }
  167. </style>
  168. <style lang="scss" scoped>
  169. .flex {
  170. display: flex;
  171. justify-content: center;
  172. }
  173. .selectCar-box {
  174. // width: 100%;
  175. height: 100%;
  176. padding: 30rpx;
  177. .item {
  178. padding: 20rpx;
  179. display: flex;
  180. justify-content: space-between;
  181. align-items: center;
  182. height: 130rpx;
  183. background: #FFFFFF;
  184. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  185. border-radius: 20rpx;
  186. margin-bottom: 30rpx;
  187. .iten-left {
  188. align-items: center;
  189. font-size: 28rpx;
  190. text {
  191. margin-left: 20rpx;
  192. font-size: 32rpx;
  193. font-family: Noto Sans S Chinese;
  194. font-weight: 400;
  195. color: #333333;
  196. }
  197. }
  198. .choose-item {
  199. width: 44rpx;
  200. height: 44rpx;
  201. background: #FFFFFF;
  202. border: 2rpx solid #00B38B;
  203. border-radius: 50%;
  204. margin-right: 20rpx;
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. box-sizing: content-box;
  209. }
  210. .active {
  211. width: 34rpx;
  212. height: 34rpx;
  213. background: #00B38B;
  214. border-radius: 50%;
  215. }
  216. }
  217. }
  218. </style>