index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="page" :style="{'height':windowHeight}">
  3. <scroll-view scroll-y :style="{'height':windowHeight}">
  4. <view class="row-list flex-row justify-start" v-for="(item,index) in equityList" :key="index">
  5. <view class="h-text flex-col justify-center ">
  6. <view class="money">
  7. <text>¥{{item.salePrice}}</text>
  8. </view>
  9. <!-- <view class="desc">-->
  10. <!-- <text>{{item.title}}</text>-->
  11. <!-- </view>-->
  12. </view>
  13. <view class="h-center-content flex-col justify-around">
  14. <view class="h-value">
  15. <text>{{item.title}}</text>
  16. </view>
  17. <view class="title">
  18. 使用项目:{{item.serviceProjectName || ''}}
  19. </view>
  20. <view class="title">
  21. 有效天数:{{item.effectiveDays}}
  22. </view>
  23. </view>
  24. <view class="h-right-content flex-col justify-center ">
  25. <view class="btn" @click="payRights(item)">
  26. <text>购买</text>
  27. </view>
  28. </view>
  29. </view>
  30. </scroll-view>
  31. <uni-popup ref="popup" :catchtouchmove="true" :animation="false" type="bottom">
  32. <view class=" payView">
  33. <view class="flex-row justify-between">
  34. <text class="payType">请选择支付方式</text>
  35. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  36. </view>
  37. <view class="payTitle">
  38. <text>选择微信支付或余额支付</text>
  39. </view>
  40. <view class="payItem flex-row justify-between" @click="payItem(1)">
  41. <view class="flex-row">
  42. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  43. <view class="payName flex-col justify-center">
  44. <text>余额支付</text>
  45. <text class="balance">可以余额¥{{userInfo.balance || 0}}</text>
  46. </view>
  47. </view>
  48. <view class="flex-col justify-center">
  49. <view v-if="curServiceTab === 1" >
  50. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  51. </view>
  52. <view v-else>
  53. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="payItem flex-row justify-between" @click="payItem(2)">
  58. <view class="flex-row">
  59. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  60. <view class="payName flex-col justify-center">
  61. <text>微信支付</text>
  62. </view>
  63. </view>
  64. <view class="flex-col justify-center">
  65. <view v-if="curServiceTab === 2" >
  66. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  67. </view>
  68. <view v-else>
  69. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="commitBtn" @click="commonGeneralOrder">
  74. <text>确定</text>
  75. </view>
  76. </view>
  77. </uni-popup>
  78. <u-picker :show="show" title="选择服务对象" :closeOnClickOverlay="true" @close="show = false" :columns="serviceObjectList" keyName="nickName" @cancel="show = false" @confirm="confirm"></u-picker>
  79. </view>
  80. </template>
  81. <script>
  82. export default {
  83. data() {
  84. return {
  85. windowHeight:'',
  86. show:false,
  87. curServiceTab:1,
  88. orderRights:{},
  89. userInfo:{},
  90. serviceObjectList:[],
  91. serviceObjectIndex:0,
  92. equityList:[],
  93. serviceObject:{},
  94. orderNo:''
  95. };
  96. },
  97. onLoad(option) {
  98. let sysInfo = uni.getSystemInfoSync()
  99. this.windowHeight =sysInfo.windowHeight - 44 +'px'//除标题栏栏外的屏幕可用高度
  100. this.userInfo = uni.getStorageSync('userInfo')
  101. this.listServiceObject()
  102. this.equityCardList()
  103. },
  104. methods: {
  105. commonGeneralOrder(){
  106. this.$refs.popup.close()
  107. this.$api.commonGeneralOrder({
  108. orderType: 5,
  109. serviceObjectId: this.serviceObject.id,
  110. equityCardId:this.orderRights.id
  111. }).then(res=>{
  112. this.orderNo=res.data.data.orderNo
  113. if (this.curServiceTab === 1){
  114. //开启余额支付
  115. this.balancePay()
  116. }
  117. if (this.curServiceTab === 2){
  118. //调微信支付
  119. this.wechatPay()
  120. }
  121. })
  122. },
  123. //余额支付
  124. balancePay(){
  125. let that = this;
  126. this.$api.balancePay({
  127. orderNo: this.orderNo,
  128. password: ''
  129. }).then((res)=>{
  130. uni.showToast({
  131. title: '支付成功!'
  132. });
  133. this.getUserInfo()
  134. }).catch((res) =>{
  135. console.log(res)
  136. that.$refs.popup.close()
  137. let msg = res.data.msg || '操作失败';
  138. uni.showToast({
  139. title: msg,
  140. icon:'error'
  141. })
  142. });
  143. },
  144. wechatPay(){
  145. let that = this;
  146. // 发起微信支付
  147. this.$api.wechatPay({
  148. orderNo:this.orderNo
  149. }).then((res)=>{
  150. var param = res.data.data;
  151. uni.requestPayment({
  152. appId: param.appid,
  153. timeStamp: param.timestamp+"",
  154. nonceStr: param.noncestr,
  155. package: "prepay_id="+param.prepayid,
  156. signType: "RSA",
  157. paySign: param.sign,
  158. success: res => {
  159. uni.showToast({
  160. title: '支付成功!'
  161. });
  162. },
  163. fail: res => {
  164. console.log(res)
  165. uni.showModal({
  166. content: '支付失败',
  167. showCancel: false
  168. });
  169. }
  170. });
  171. })
  172. },
  173. getUserInfo(){
  174. this.$api.getUserInfo().then(res=>{
  175. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  176. uni.setStorageSync('userInfo',res.data.data)
  177. this.userInfo = res.data.data
  178. })
  179. },
  180. confirm(e){
  181. console.log(e)
  182. this.serviceObject = e.value[0]
  183. this.show = false
  184. this.$refs.popup.open()
  185. },
  186. equityCardList(){
  187. this.$api.equityCardList().then(res=>{
  188. console.log(res)
  189. this.equityList = res.data.data
  190. })
  191. },
  192. // 查询服务对像信息列表
  193. listServiceObject(){
  194. this.$api.listServiceObject(this.reqParm).then((res)=>{
  195. this.serviceObjectList[0] =res.data.data
  196. })
  197. },
  198. closePayPopup(){
  199. this.$refs.popup.close()
  200. },
  201. payItem(num){
  202. if (this.userInfo.balance < this.price){
  203. return
  204. }
  205. this.curServiceTab = num
  206. },
  207. payRights(item){
  208. this.show =true
  209. this.orderRights = item
  210. }
  211. },
  212. };
  213. </script>
  214. <style lang="scss" scoped>
  215. @import '/common/css/common.css';
  216. @import './index.rpx.scss';
  217. </style>