index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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:2,
  106. orderRights:{},
  107. userInfo:{},
  108. serviceObjectList:[],
  109. serviceObjectIndex:0,
  110. equityList:[],
  111. serviceObject:{},
  112. orderNo:''
  113. };
  114. },
  115. onLoad(option) {
  116. this.userInfo = uni.getStorageSync('userInfo')
  117. let sysInfo = uni.getSystemInfoSync()
  118. this.windowHeight =sysInfo.windowHeight -50 +'px'//除标题栏栏外的屏幕可用高度
  119. this.windowHeight1 =sysInfo.windowHeight +'px'//除标题栏栏外的屏幕可用高度
  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. })
  162. },
  163. wechatPay(){
  164. let that = this;
  165. // 发起微信支付
  166. this.$api.wechatPay({
  167. orderNo:this.orderNo
  168. }).then((res)=>{
  169. var param = res.data.data;
  170. uni.requestPayment({
  171. appId: param.appid,
  172. timeStamp: param.timestamp+"",
  173. nonceStr: param.noncestr,
  174. package: "prepay_id="+param.prepayid,
  175. signType: "RSA",
  176. paySign: param.sign,
  177. success: res => {
  178. uni.showToast({
  179. title: '支付成功!'
  180. });
  181. },
  182. fail: res => {
  183. console.log(res)
  184. uni.showModal({
  185. content: '支付失败',
  186. showCancel: false
  187. });
  188. }
  189. });
  190. })
  191. },
  192. getUserInfo(){
  193. this.$api.getUserInfo().then(res=>{
  194. console.log('++++++++++++获取用户信息++++++++++++++++++',res)
  195. uni.setStorageSync('userInfo',res.data.data)
  196. this.userInfo = res.data.data
  197. })
  198. },
  199. confirm(e){
  200. console.log(e)
  201. this.serviceObject = e.value[0]
  202. this.show = false
  203. this.$refs.popup.open()
  204. },
  205. equityCardList(){
  206. this.$api.equityCardList().then(res=>{
  207. console.log(res)
  208. this.equityList = res.data.data
  209. })
  210. },
  211. // 查询服务对像信息列表
  212. listServiceObject(){
  213. let serviceObjectList =[]
  214. this.$api.listServiceObject(this.reqParm).then((res)=>{
  215. res.data.data.forEach(i=>{
  216. if (i.isSelf != 1){
  217. serviceObjectList.push(i)
  218. }
  219. })
  220. this.serviceObjectList[0] =serviceObjectList
  221. })
  222. },
  223. closePayPopup(){
  224. this.$refs.popup.close()
  225. },
  226. payItem(num){
  227. if (this.userInfo.balance*1 < this.orderRights.salePrice*1){
  228. return
  229. }
  230. this.curServiceTab = num
  231. },
  232. payRights(item){
  233. if (this.serviceObjectList[0].length===0){
  234. uni.showModal({
  235. title:'温馨提示',
  236. content:'购买权益卡时须绑定服务对象,是否前往绑定服务对象',
  237. success:res=>{
  238. if (res.confirm){
  239. uni.navigateTo({
  240. url: '/myPages/ServiceObjectManagement/index',
  241. })
  242. }
  243. }
  244. })
  245. return;
  246. }
  247. if(!this.selectIcon){
  248. uni.$u.toast('请阅读并同意《娇骄儿88卡权益服务协议》')
  249. return;
  250. }
  251. this.show =true
  252. this.orderRights = item
  253. }
  254. },
  255. };
  256. </script>
  257. <style lang="scss" scoped>
  258. @import '/common/css/common.css';
  259. @import './index.rpx.scss';
  260. </style>