index.vue 7.3 KB

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