Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

equityList.vue 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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.name }}</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="chooseBuy(item.equityId)">去支付</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,StorageKeys
  20. } from "@/utils/storage";
  21. import {
  22. ref
  23. } from 'vue';
  24. import {
  25. requestNew
  26. } from "@/utils/network/request.js";
  27. import {
  28. equitypurchasepage,equitypurchase,getOpenId,paymentequityapplyapp,payequitydetection
  29. } from "@/utils/network/api.js";
  30. import {
  31. stringToJson
  32. } from "@/utils/network/encryption";
  33. import { msg } from "@/utils/utils";
  34. import {onShow} from "@dcloudio/uni-app";
  35. let listData = ref([])
  36. const state = reactive({
  37. id: "", //支付id
  38. });
  39. onShow(()=>{
  40. query()
  41. })
  42. function query(){
  43. //卡券渠道类型获取单项权益列表
  44. requestNew(equitypurchasepage, {
  45. type: 2,
  46. data: {
  47. couponAgencyType: ['TUHU', 'ZFB'],
  48. mobile: getItem('mobile').toString()
  49. },
  50. method: "POST",
  51. showLoading: true,
  52. }).then((item) => {
  53. let res = item
  54. console.log(res, '=========');
  55. listData.value = res.result
  56. })
  57. }
  58. function onClick(singId: any) {
  59. uni.navigateTo({
  60. url: '/subpackage/service/equity/equity?singleEquityId=' + singId.singleEquityId +
  61. '&couponAgencyType=' + singId.couponAgencyType + '&couponId=' + singId.couponId + '&equityId=' + singId.equityId,
  62. })
  63. }
  64. const chooseBuy = (equityId) => {
  65. const options = {
  66. type: 2,
  67. data: {
  68. "openId": getItem(StorageKeys.OpenId),
  69. "equityId": equityId
  70. },
  71. method: 'POST',
  72. showLoading: true,
  73. }
  74. // 权益购买入参有个属性是type:1,代表查询是否已经买过了权益,返回的数据中hasData:true表示买过了,如果hasData:false表示没买过。type:2,表示购买
  75. requestNew(equitypurchase, options).then((res) => {
  76. const data = res;
  77. console.log("购买2", data)
  78. state.id = data.id
  79. // 权益支付下单
  80. equityPaymentOrderRequest()
  81. })
  82. }
  83. // 权益支付下单
  84. const equityPaymentOrderRequest = () => {
  85. // #ifdef MP-WEIXIN
  86. uni.login({
  87. provider: "weixin",
  88. success: function (e) {
  89. const options1 = {
  90. type: 2,
  91. data: {
  92. "jsCode": e.code
  93. },
  94. method: "POST",
  95. showLoading: true,
  96. };
  97. requestNew(getOpenId, options1).then((res) => {
  98. console.log("state.id",state.id)
  99. console.log("state.id",res)
  100. const result = res;
  101. const openidData = stringToJson(result.data);
  102. console.log("openidData",openidData)
  103. const options = {
  104. type: 2,
  105. data: {
  106. id: state.id,
  107. payType: "EQUITY",
  108. wxOpenid: openidData.openid,
  109. // openId: openidData.openid,
  110. },
  111. method: 'POST',
  112. showLoading: true,
  113. }
  114. requestNew(paymentequityapplyapp, options).then((res) => {
  115. const data = res;
  116. console.log("权益支付下单", data)
  117. if (data.info == "购买权益记录已支付") {
  118. uni.showModal({
  119. title: '提示',
  120. content: data.info,
  121. showCancel: false,
  122. success: function (res) {
  123. if (res.confirm) {
  124. uni.navigateBack({
  125. delta: 2
  126. })
  127. }
  128. }
  129. });
  130. } else {
  131. uni.requestPayment({
  132. provider: "wxpay",
  133. orderInfo: "",
  134. timeStamp: data.timestamp,
  135. nonceStr: data.noncestr,
  136. package: data.wxPackage ? data.wxPackage : "",
  137. signType: data.signType,
  138. paySign: data.sign,
  139. success: function (e) {
  140. console.log("支付成功", res);
  141. // 权益支付检测
  142. equityPaymentTestRequest().then((item : any) => {
  143. console.log("权益支付检测", data)
  144. msg("权益产品购买成功")
  145. // 重新查询一遍
  146. query()
  147. })
  148. },
  149. fail: function (err) {
  150. confirm(err, () => { }, "支付失败", false);
  151. },
  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. requestNew(paymentequityapplyapp, 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. msg("权益产品购买成功,到【我的】权益查看")
  201. setTimeout(() => {
  202. uni.navigateBack({
  203. delta: 2
  204. })
  205. }, 2000)
  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 requestNew(payequitydetection, options);
  234. const data = res;
  235. resolve(data);
  236. }).catch((error) => {
  237. reject(error);
  238. });
  239. }
  240. </script>
  241. <style lang='scss' scoped>
  242. .item{
  243. background-color: #22dbc8;
  244. color: white;
  245. border-radius: 20rpx;
  246. padding: 15px 30rpx;
  247. margin: 20rpx;
  248. font-size: 28rpx;
  249. }
  250. .btn {
  251. height: 50rpx;
  252. line-height: 50rpx;
  253. border-radius: 30rpx;
  254. padding: 0 24rpx;
  255. font-size: 23rpx;
  256. box-sizing: border-box;
  257. margin-right: 12rpx;
  258. border: 1px solid #fff;
  259. color: #fff;
  260. display: inline-block;
  261. }
  262. .no{
  263. text-align: center;
  264. margin: 40rpx auto;
  265. font-size: 28rpx;
  266. }
  267. </style>