index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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">《娇骄儿权益服务协议》</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"
  95. keyName="nickName" @cancel="show = false" @confirm="confirm"></u-picker>
  96. </view>
  97. </template>
  98. <script>
  99. export default {
  100. data() {
  101. return {
  102. selectIcon: '',
  103. windowHeight: '',
  104. windowHeight1: '',
  105. show: false,
  106. curServiceTab: 2,
  107. orderRights: {},
  108. userInfo: {},
  109. serviceObjectList: [],
  110. serviceObjectIndex: 0,
  111. equityList: [],
  112. serviceObject: {},
  113. orderNo: ''
  114. };
  115. },
  116. onLoad(option) {
  117. this.userInfo = uni.getStorageSync('userInfo')
  118. let sysInfo = uni.getSystemInfoSync()
  119. this.windowHeight = sysInfo.windowHeight - 50 + 'px'//除标题栏栏外的屏幕可用高度
  120. this.windowHeight1 = sysInfo.windowHeight + 'px'//除标题栏栏外的屏幕可用高度
  121. this.listServiceObject()
  122. this.equityCardList()
  123. },
  124. methods: {
  125. goTermsOfService() {
  126. uni.navigateTo({
  127. url: '/myPages/TermsOfService/index?name=' + '娇骄儿权益服务协议' + '&type=' + 4
  128. })
  129. },
  130. selectChange() {
  131. this.selectIcon = !this.selectIcon
  132. },
  133. commonGeneralOrder() {
  134. let promotionParam = uni.getStorageSync('promotionParam')
  135. this.$refs.popup.close()
  136. this.$api.commonGeneralOrder({
  137. ...promotionParam,
  138. orderType: 5,
  139. serviceObjectId: this.serviceObject.id,
  140. equityCardId: this.orderRights.id
  141. }).then(res => {
  142. this.orderNo = res.data.data.orderNo
  143. if (this.curServiceTab === 1) {
  144. //开启余额支付
  145. this.balancePay()
  146. }
  147. if (this.curServiceTab === 2) {
  148. //调微信支付
  149. this.wechatPay()
  150. }
  151. })
  152. },
  153. //余额支付
  154. balancePay() {
  155. let that = this;
  156. this.$api.balancePay({
  157. orderNo: this.orderNo,
  158. password: ''
  159. }).then((res) => {
  160. uni.showToast({
  161. title: '支付成功!'
  162. });
  163. this.getUserInfo()
  164. })
  165. },
  166. wechatPay() {
  167. let that = this;
  168. // 发起微信支付
  169. this.$api.wechatPay({
  170. orderNo: this.orderNo
  171. }).then((res) => {
  172. var param = res.data.data;
  173. uni.requestPayment({
  174. appId: param.appid,
  175. timeStamp: param.timestamp + "",
  176. nonceStr: param.noncestr,
  177. package: "prepay_id=" + param.prepayid,
  178. signType: "RSA",
  179. paySign: param.sign,
  180. success: res => {
  181. uni.showToast({
  182. title: '支付成功!'
  183. });
  184. setTimeout(() => {
  185. uni.navigateTo({
  186. url: '/storePages/myRights/index'
  187. });
  188. }, 2000)
  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. let serviceObjectList = []
  222. this.$api.listServiceObject(this.reqParm).then((res) => {
  223. res.data.data.forEach(i => {
  224. if (i.isSelf != 1) {
  225. serviceObjectList.push(i)
  226. }
  227. })
  228. this.serviceObjectList[0] = serviceObjectList
  229. })
  230. },
  231. closePayPopup() {
  232. this.$refs.popup.close()
  233. },
  234. payItem(num) {
  235. if (this.userInfo.balance * 1 < this.orderRights.salePrice * 1) {
  236. return
  237. }
  238. this.curServiceTab = num
  239. },
  240. payRights(item) {
  241. if (this.serviceObjectList[0].length === 0) {
  242. uni.showModal({
  243. title: '温馨提示',
  244. content: '默认服务对象不能使用权益卡,是否前往绑定新的服务对象?',
  245. success: res => {
  246. if (res.confirm) {
  247. uni.navigateTo({
  248. url: '/myPages/ServiceObjectManagement/index',
  249. })
  250. }
  251. }
  252. })
  253. return;
  254. }
  255. if (!this.selectIcon) {
  256. uni.$u.toast('请阅读并同意《娇骄儿权益服务协议》')
  257. return;
  258. }
  259. this.show = true
  260. this.orderRights = item
  261. }
  262. },
  263. };
  264. </script>
  265. <style lang="scss" scoped>
  266. @import '/common/css/common.css';
  267. @import './index.rpx.scss';
  268. </style>