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.5KB

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