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.

equityList.vue 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view>
  3. <view v-for="(item, index) in listData" :key="index" @click="onClick(item)" :data-code="item" class="item">
  4. <view style="display: flex;justify-content: space-between;">
  5. <text>{{ item.productName }}</text><text>></text>
  6. </view>
  7. <view style="display: flex;justify-content: flex-end;margin-top: 6rpx;">
  8. <!-- 是否支付 1-已支付,2-未支付支付,3-已取消,4-已下单,未支付 -->
  9. <text class="btn" v-if="item.isPay==2"
  10. @click.stop="equityPaymentOrderRequest(item.id)">去支付</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view v-if="listData.length==0" class="no">暂无数据</view>
  15. </template>
  16. <script setup lang='ts'>
  17. import { reactive } from "vue";
  18. import {
  19. getItem
  20. } from "@/utils/storage";
  21. import {
  22. ref
  23. } from 'vue';
  24. import {
  25. requestNew
  26. } from "@/utils/network/request.js";
  27. import {getOpenId,paymentequityapplyapp,payequitydetection,queryuserallequity} from "@/utils/network/api.js";
  28. import {
  29. stringToJson
  30. } from "@/utils/network/encryption";
  31. import { msg } from "@/utils/utils";
  32. import {onShow} from "@dcloudio/uni-app";
  33. let listData = ref([])
  34. const state = reactive({
  35. id: "", //支付id
  36. });
  37. onShow(()=>{
  38. query()
  39. })
  40. function query(){
  41. //卡券渠道类型获取单项权益列表
  42. requestNew(queryuserallequity, {
  43. type: 2,
  44. data: {
  45. couponAgencyType: ['TUHU', 'ZFB'],
  46. mobile: getItem('mobile').toString()
  47. },
  48. method: "POST",
  49. showLoading: true,
  50. }).then((item) => {
  51. let res = item
  52. console.log(res, '=========');
  53. listData.value = res.data
  54. })
  55. }
  56. function onClick(singId: any) {
  57. uni.navigateTo({
  58. url: '/subpackage/service/equity/equity?singleEquityId=' + singId.singleEquityId +
  59. '&couponAgencyType=' + singId.couponAgencyType + '&couponId=' + singId.couponId + '&equityId=' + singId.equityId+ '&purchasedEquityId=' + singId.eporderId,
  60. })
  61. }
  62. // 权益支付下单
  63. const equityPaymentOrderRequest = (id) => {
  64. state.id =id
  65. // #ifdef MP-WEIXIN
  66. uni.login({
  67. provider: "weixin",
  68. success: function (e) {
  69. const options1 = {
  70. type: 2,
  71. data: {
  72. "jsCode": e.code
  73. },
  74. method: "POST",
  75. showLoading: true,
  76. };
  77. requestNew(getOpenId, options1).then((res) => {
  78. console.log("state.id",id)
  79. const result = res;
  80. const openidData = stringToJson(result.data);
  81. console.log("openidData",openidData)
  82. const options = {
  83. type: 2,
  84. data: {
  85. id: id,
  86. payType: "EQUITY",
  87. wxOpenid: openidData.openid,
  88. },
  89. method: 'POST',
  90. showLoading: true,
  91. }
  92. requestNew(paymentequityapplyapp, options).then((res) => {
  93. const data = res;
  94. console.log("权益支付下单", data)
  95. if (data.info == "购买权益记录已支付") {
  96. uni.showModal({
  97. title: '提示',
  98. content: data.info,
  99. showCancel: false,
  100. success: function (res) {
  101. if (res.confirm) {
  102. uni.navigateBack({
  103. delta: 2
  104. })
  105. }
  106. }
  107. });
  108. } else {
  109. uni.requestPayment({
  110. provider: "wxpay",
  111. orderInfo: "",
  112. timeStamp: data.timestamp,
  113. nonceStr: data.noncestr,
  114. package: data.wxPackage ? data.wxPackage : "",
  115. signType: data.signType,
  116. paySign: data.sign,
  117. success: function (e) {
  118. console.log("支付成功", res);
  119. // 权益支付检测
  120. equityPaymentTestRequest().then((item : any) => {
  121. console.log("权益支付检测", data)
  122. msg("权益产品购买成功")
  123. // 重新查询一遍
  124. query()
  125. })
  126. },
  127. fail: function (err) {
  128. confirm(err, () => { }, "支付失败", false);
  129. },
  130. })
  131. }
  132. })
  133. })
  134. },
  135. })
  136. // #endif
  137. // #ifdef MP-ALIPAY
  138. my.getAuthCode({
  139. scopes: 'auth_base',
  140. success: res => {
  141. const optionsUser = {
  142. type: 2,
  143. data: {
  144. payConfigId: aliPayConfigIdTwo,
  145. code: res.authCode
  146. },
  147. method: "POST",
  148. showLoading: true,
  149. };
  150. console.log('支付宝用户编号请求:', optionsUser)
  151. request(obtainUserId, optionsUser).then((res) => {
  152. console.log('支付宝用户编号返回:', res)
  153. const data = stringToJson(res.bizContent);
  154. console.log("data", data)
  155. const optionsali = {
  156. type: 2,
  157. data: {
  158. id: state.id,
  159. payType: "EQUITY",
  160. wxOpenid: data.openId,
  161. },
  162. method: "POST",
  163. showLoading: true,
  164. };
  165. console.log('支付下单请求:', optionsali)
  166. requestNew(paymentequityapplyapp, optionsali).then((res) => {
  167. const data = stringToJson(res.bizContent);
  168. console.log('支付下单返回:', data)
  169. my.tradePay({
  170. // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号 trade_no
  171. tradeNO: data.tranPackage,
  172. success: res => {
  173. console.log("支付成功", res);
  174. if (res.resultCode != "6001") {
  175. // 权益支付检测
  176. equityPaymentTestRequest().then((item : any) => {
  177. console.log("权益支付检测", data)
  178. msg("权益产品购买成功,到【我的】权益查看")
  179. setTimeout(() => {
  180. uni.navigateBack({
  181. delta: 2
  182. })
  183. }, 2000)
  184. })
  185. }
  186. },
  187. fail: res => {
  188. console.log("支付失败", res);
  189. },
  190. });
  191. });
  192. });
  193. },
  194. fail: err => {
  195. console.log('my.getAuthCode 调用失败', err)
  196. }
  197. });
  198. // #endif
  199. }
  200. // 权益支付检测
  201. const equityPaymentTestRequest = () => {
  202. const options = {
  203. type: 2,
  204. data: {
  205. id: state.id,
  206. },
  207. method: 'POST',
  208. showLoading: true,
  209. }
  210. return new Promise(async (resolve, reject) => {
  211. const res = await requestNew(payequitydetection, options);
  212. const data = res;
  213. resolve(data);
  214. }).catch((error) => {
  215. reject(error);
  216. });
  217. }
  218. </script>
  219. <style lang='scss' scoped>
  220. .item{
  221. background-color: #22dbc8;
  222. color: white;
  223. border-radius: 20rpx;
  224. padding: 15px 30rpx;
  225. margin: 20rpx;
  226. font-size: 28rpx;
  227. }
  228. .btn {
  229. height: 50rpx;
  230. line-height: 50rpx;
  231. border-radius: 30rpx;
  232. padding: 0 24rpx;
  233. font-size: 23rpx;
  234. box-sizing: border-box;
  235. margin-right: 12rpx;
  236. border: 1px solid #fff;
  237. color: #fff;
  238. display: inline-block;
  239. }
  240. .no{
  241. text-align: center;
  242. margin: 40rpx auto;
  243. font-size: 28rpx;
  244. }
  245. </style>