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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="selectCar-box">
  3. <view v-if="state.list" class="item" v-for="(item,i) in state.list" :key="i">
  4. <view>权益名称:{{item.name}}</view>
  5. <view>权益金额:¥{{item.fee * 0.01}}元</view>
  6. <view v-if="item.insertTime">购买时间:{{item.insertTime}}</view>
  7. <view v-if="item.payTime">支付时间:{{item.payTime}}</view>
  8. <view style="display: flex;justify-content: flex-end;">
  9. <text class="btn btn-primary" v-if="item.evaluate==1">已评价</text>
  10. <text class="btn btn-primary" v-else @click="goQuanyi(item)">去评价</text>
  11. <!-- 是否支付 1-已支付,2-未支付支付,3-已取消,4-已下单,未支付 -->
  12. <text class="btn btn-primary" v-if="item.isPay==2"
  13. @click="equityPaymentOrderRequest(item.id)">去支付</text>
  14. </view>
  15. </view>
  16. <view v-else>
  17. <empty title='暂无权益记录' />
  18. </view>
  19. <view style="text-align: center;margin: 20rpx;font-size: 30rpx;" v-if="state.flags">我是有底线的~</view>
  20. </view>
  21. </template>
  22. <script lang="ts" setup>
  23. import empty from "@/components/empty/empty.vue";
  24. import {
  25. reactive,
  26. ref
  27. } from "vue"
  28. import {
  29. msg,
  30. navTo
  31. } from "@/utils/utils"
  32. import {
  33. onLoad, onReachBottom, onShow
  34. } from "@dcloudio/uni-app";
  35. import {
  36. showEquityListApi, getOpenidApi, equityPaymentOrderApi, equityPaymentTestApi
  37. } from "@/utils/network/api.js";
  38. import {
  39. request
  40. } from "@/utils/network/request.js";
  41. import {
  42. getItem,
  43. StorageKeys,
  44. } from "@/utils/storage";
  45. import {
  46. stringToJson
  47. } from "@/utils/network/encryption";
  48. const state = reactive({
  49. list: [],//车辆list,
  50. equtyId: "",//权益id
  51. flags: false,
  52. pageSize: 10,
  53. pageNo: 1,
  54. id: ""
  55. });
  56. const flag = ref('0') //默认选择0
  57. onShow(() => {
  58. state.pageNo = 1
  59. state.list = []
  60. showEquityListRequest()
  61. })
  62. const showEquityListRequest = () => {
  63. const options = {
  64. type: 2,
  65. data: {
  66. "openId": getItem(StorageKeys.OpenId),
  67. "pageNo": state.pageNo,
  68. "pageSize": state.pageSize,
  69. },
  70. method: 'POST',
  71. showLoading: true,
  72. }
  73. request(showEquityListApi, options).then((res) => {
  74. const data = stringToJson(res.bizContent);
  75. state.list = [...state.list, ...stringToJson(res.bizContent).data]
  76. console.log("购买2", data.data, state.list.length > 0)
  77. })
  78. }
  79. onReachBottom(() => {
  80. console.log("触底了", state.list.length, state.pageNo * 10)
  81. if (state.list.length < state.pageNo * 10) return state.flags = true
  82. console.log("触底了")
  83. state.pageNo++
  84. showEquityListRequest()
  85. })
  86. const goQuanyi = (item) => {
  87. navTo(`/subpackage/after-sale/add-equity/equity-product-evaluation?equityId=${item.equityId}&id=${item.id}&orderId=${item.orderId}`)
  88. }
  89. // 权益支付下单
  90. const equityPaymentOrderRequest = (id) => {
  91. state.id = id
  92. uni.login({
  93. provider: "weixin",
  94. success: function (e) {
  95. const options1 = {
  96. type: 2,
  97. data: {
  98. "jsCode": e.code
  99. },
  100. method: "POST",
  101. showLoading: true,
  102. };
  103. request(getOpenidApi, options1).then((res) => {
  104. const result = stringToJson(res.bizContent);
  105. const openidData = stringToJson(result.data);
  106. const options = {
  107. type: 2,
  108. data: {
  109. id: state.id,
  110. payType: "EQUITY",
  111. wxOpenid: openidData.openid,
  112. },
  113. method: 'POST',
  114. showLoading: true,
  115. }
  116. request(equityPaymentOrderApi, options).then((res) => {
  117. const data = stringToJson(res.bizContent);
  118. console.log("权益支付下单", data)
  119. uni.requestPayment({
  120. provider: "wxpay",
  121. orderInfo: "",
  122. timeStamp: data.timestamp,
  123. nonceStr: data.noncestr,
  124. package: data.wxPackage ? data.wxPackage : "",
  125. signType: data.signType,
  126. paySign: data.sign,
  127. success: function (e) {
  128. console.log("支付成功", res);
  129. equityPaymentTestRequest().then((item : any) => {
  130. msg("权益产品购买成功")
  131. state.pageNo = 1
  132. state.list = []
  133. showEquityListRequest()
  134. })
  135. },
  136. fail: function (err) {
  137. confirm(err, () => { }, "支付失败", false);
  138. },
  139. })
  140. })
  141. })
  142. },
  143. })
  144. }
  145. // 权益支付检测
  146. const equityPaymentTestRequest = () => {
  147. const options = {
  148. type: 2,
  149. data: {
  150. id: state.id,
  151. },
  152. method: 'POST',
  153. showLoading: true,
  154. }
  155. return new Promise(async (resolve, reject) => {
  156. const res = await request(equityPaymentTestApi, options);
  157. const data = stringToJson(res.bizContent);
  158. resolve(data);
  159. }).catch((error) => {
  160. reject(error);
  161. });
  162. }
  163. </script>
  164. <style>
  165. page {
  166. width: 100%;
  167. height: 100%;
  168. background-color: #EEF7F7;
  169. }
  170. </style>
  171. <style lang="scss" scoped>
  172. .selectCar-box {
  173. padding: 30rpx;
  174. .item {
  175. padding: 20rpx;
  176. align-items: center;
  177. font-size: 30rpx;
  178. background: #FFFFFF;
  179. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  180. border-radius: 20rpx;
  181. margin-bottom: 30rpx;
  182. .iten-left {
  183. align-items: center;
  184. font-size: 30rpx;
  185. text {
  186. margin-left: 20rpx;
  187. font-size: 32rpx;
  188. font-family: Noto Sans S Chinese;
  189. font-weight: 400;
  190. color: #333333;
  191. }
  192. }
  193. .choose-item {
  194. width: 44rpx;
  195. height: 44rpx;
  196. background: #FFFFFF;
  197. border: 2rpx solid #00B38B;
  198. border-radius: 50%;
  199. margin-right: 20rpx;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. box-sizing: content-box;
  204. }
  205. .active {
  206. width: 34rpx;
  207. height: 34rpx;
  208. background: #00B38B;
  209. border-radius: 50%;
  210. }
  211. }
  212. }
  213. .btn-primary {
  214. border: 1px solid #00b38b;
  215. color: #00b38b;
  216. }
  217. .btn {
  218. height: 50rpx;
  219. line-height: 50rpx;
  220. border-radius: 30rpx;
  221. padding: 0 24rpx;
  222. font-size: 23rpx;
  223. box-sizing: border-box;
  224. margin-right: 12rpx;
  225. }
  226. </style>