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.

equity-list.vue 8.0KB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
7 months ago
1 year ago
7 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
7 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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, getOpenId, equityPaymentOrderApi, equityPaymentTestApi, obtainUserId, aliPayConfigIdTwo
  37. } from "@/utils/network/api.js";
  38. import {
  39. request, requestNew
  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. totalCount: "",//总条数
  56. });
  57. const flag = ref('0') //默认选择0
  58. onShow(() => {
  59. state.pageNo = 1
  60. state.list = []
  61. showEquityListRequest()
  62. })
  63. const showEquityListRequest = () => {
  64. const options = {
  65. type: 2,
  66. data: {
  67. "openId": getItem(StorageKeys.OpenId),
  68. "pageNo": state.pageNo,
  69. "pageSize": state.pageSize,
  70. },
  71. method: 'POST',
  72. showLoading: true,
  73. }
  74. request(showEquityListApi, options).then((res) => {
  75. const data = stringToJson(res.bizContent);
  76. state.totalCount = data.totalCount
  77. let dataAll = [...state.list, ...stringToJson(res.bizContent).data]
  78. for (var i = 0; i < dataAll.length; i++) {
  79. console.log("111", dataAll[i]['insertTime'], dataAll[i]['insertTime'].replace("T", " "))
  80. if (dataAll[i]['insertTime']) {
  81. dataAll[i]['insertTime'] = dataAll[i]['insertTime'].replace("T", " ")
  82. }
  83. if (dataAll[i]['payTime']) {
  84. dataAll[i]['payTime'] = dataAll[i]['payTime'].replace("T", " ")
  85. }
  86. }
  87. state.list = dataAll
  88. console.log("购买2", data.totalCount, data.data, state.list.length > 0)
  89. })
  90. }
  91. onReachBottom(() => {
  92. console.log("触底了", state.list.length, state.pageNo * 10)
  93. if (Number(state.totalCount) == state.list.length) return state.flags = true
  94. if (state.list.length < state.pageNo * 10) return state.flags = true
  95. console.log("触底了")
  96. state.pageNo++
  97. showEquityListRequest()
  98. })
  99. const goQuanyi = (item) => {
  100. navTo(`/subpackage/after-sale/add-equity/equity-product-evaluation?equityId=${item.equityId}&id=${item.id}&orderId=${item.orderId}`)
  101. }
  102. // 权益支付下单
  103. const equityPaymentOrderRequest = (id) => {
  104. state.id = id
  105. // #ifdef MP-WEIXIN
  106. uni.login({
  107. provider: "weixin",
  108. success: function (e) {
  109. const options1 = {
  110. type: 2,
  111. data: {
  112. "jsCode": e.code
  113. },
  114. method: "POST",
  115. showLoading: true,
  116. };
  117. requestNew(getOpenId, options1).then((res) => {
  118. const result = res;
  119. const openidData = stringToJson(result.data);
  120. const options = {
  121. type: 2,
  122. data: {
  123. id: state.id,
  124. payType: "EQUITY",
  125. wxOpenid: openidData.openid,
  126. },
  127. method: 'POST',
  128. showLoading: true,
  129. }
  130. request(equityPaymentOrderApi, options).then((res) => {
  131. const data = stringToJson(res.bizContent);
  132. console.log("权益支付下单", data)
  133. uni.requestPayment({
  134. provider: "wxpay",
  135. orderInfo: "",
  136. timeStamp: data.timestamp,
  137. nonceStr: data.noncestr,
  138. package: data.wxPackage ? data.wxPackage : "",
  139. signType: data.signType,
  140. paySign: data.sign,
  141. success: function (e) {
  142. console.log("支付成功", res);
  143. equityPaymentTestRequest().then((item : any) => {
  144. msg("权益产品购买成功")
  145. state.pageNo = 1
  146. state.list = []
  147. showEquityListRequest()
  148. })
  149. },
  150. fail: function (err) {
  151. confirm(err, () => { }, "支付失败", false);
  152. },
  153. })
  154. })
  155. })
  156. },
  157. })
  158. // #endif
  159. // #ifdef MP-ALIPAY
  160. my.getAuthCode({
  161. scopes: 'auth_base',
  162. success: res => {
  163. const optionsUser = {
  164. type: 2,
  165. data: {
  166. payConfigId: aliPayConfigIdTwo,
  167. code: res.authCode
  168. },
  169. method: "POST",
  170. showLoading: true,
  171. };
  172. console.log('支付宝用户编号请求:', optionsUser)
  173. request(obtainUserId, optionsUser).then((res) => {
  174. console.log('支付宝用户编号返回:', res)
  175. const data = stringToJson(res.bizContent);
  176. console.log("data", data)
  177. const optionsali = {
  178. type: 2,
  179. data: {
  180. id: state.id,
  181. payType: "EQUITY",
  182. wxOpenid: data.openId,
  183. },
  184. method: "POST",
  185. showLoading: true,
  186. };
  187. console.log('支付下单请求:', optionsali)
  188. request(equityPaymentOrderApi, optionsali).then((res) => {
  189. const data = stringToJson(res.bizContent);
  190. console.log('支付下单返回:', data)
  191. my.tradePay({
  192. // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号 trade_no
  193. tradeNO: data.tranPackage,
  194. success: res => {
  195. console.log("支付成功", res);
  196. if (res.resultCode != "6001") {
  197. // 权益支付检测
  198. equityPaymentTestRequest().then((item : any) => {
  199. console.log("权益支付检测", data)
  200. equityPaymentTestRequest().then((item : any) => {
  201. msg("权益产品购买成功")
  202. state.pageNo = 1
  203. state.list = []
  204. showEquityListRequest()
  205. })
  206. })
  207. }
  208. },
  209. fail: res => {
  210. console.log("支付失败", res);
  211. },
  212. });
  213. });
  214. });
  215. },
  216. fail: err => {
  217. console.log('my.getAuthCode 调用失败', err)
  218. }
  219. });
  220. // #endif
  221. }
  222. // 权益支付检测
  223. const equityPaymentTestRequest = () => {
  224. const options = {
  225. type: 2,
  226. data: {
  227. id: state.id,
  228. },
  229. method: 'POST',
  230. showLoading: true,
  231. }
  232. return new Promise(async (resolve, reject) => {
  233. const res = await request(equityPaymentTestApi, options);
  234. const data = stringToJson(res.bizContent);
  235. resolve(data);
  236. }).catch((error) => {
  237. reject(error);
  238. });
  239. }
  240. </script>
  241. <style>
  242. page {
  243. width: 100%;
  244. height: 100%;
  245. background-color: #EEF7F7;
  246. }
  247. </style>
  248. <style lang="scss" scoped>
  249. .selectCar-box {
  250. padding: 30rpx;
  251. .item {
  252. padding: 20rpx;
  253. align-items: center;
  254. font-size: 30rpx;
  255. background: #FFFFFF;
  256. box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(223, 223, 223, 0.8);
  257. border-radius: 20rpx;
  258. margin-bottom: 30rpx;
  259. .iten-left {
  260. align-items: center;
  261. font-size: 30rpx;
  262. text {
  263. margin-left: 20rpx;
  264. font-size: 32rpx;
  265. font-family: Noto Sans S Chinese;
  266. font-weight: 400;
  267. color: #333333;
  268. }
  269. }
  270. .choose-item {
  271. width: 44rpx;
  272. height: 44rpx;
  273. background: #FFFFFF;
  274. border: 2rpx solid #00B38B;
  275. border-radius: 50%;
  276. margin-right: 20rpx;
  277. display: flex;
  278. justify-content: center;
  279. align-items: center;
  280. box-sizing: content-box;
  281. }
  282. .active {
  283. width: 34rpx;
  284. height: 34rpx;
  285. background: #00B38B;
  286. border-radius: 50%;
  287. }
  288. }
  289. }
  290. .btn-primary {
  291. border: 1px solid #00b38b;
  292. color: #00b38b;
  293. }
  294. .btn {
  295. height: 50rpx;
  296. line-height: 50rpx;
  297. border-radius: 30rpx;
  298. padding: 0 24rpx;
  299. font-size: 23rpx;
  300. box-sizing: border-box;
  301. margin-right: 12rpx;
  302. }
  303. </style>