index.vue 6.3 KB

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