index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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="payItem flex-row justify-between" @click="payItem(2)">
  54. <view class="flex-row">
  55. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  56. <view class="payName flex-col justify-center">
  57. <text>微信支付</text>
  58. </view>
  59. </view>
  60. <view class="flex-col justify-center">
  61. <view v-if="curServiceTab === 2">
  62. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  63. </view>
  64. <view v-else>
  65. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="commitBtn" @click="commonGeneralOrder">
  70. <text>确定</text>
  71. </view>
  72. </view>
  73. </uni-popup>
  74. <u-picker :show="show" title="选择服务对象" :closeOnClickOverlay="true" @close="show = false" :columns="serviceObjectList"
  75. keyName="nickName" @cancel="show = false" @confirm="confirm"></u-picker>
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. data() {
  81. return {
  82. selectIcon: '',
  83. windowHeight: '',
  84. windowHeight1: '',
  85. show: false,
  86. curServiceTab: 2,
  87. orderRights: {},
  88. userInfo: {},
  89. serviceObjectList: [],
  90. serviceObjectIndex: 0,
  91. equityList: [],
  92. serviceObject: {},
  93. orderNo: ''
  94. };
  95. },
  96. onLoad(option) {
  97. this.userInfo = uni.getStorageSync('userInfo')
  98. let sysInfo = uni.getSystemInfoSync()
  99. this.windowHeight = sysInfo.windowHeight - 50 + 'px'//除标题栏栏外的屏幕可用高度
  100. this.windowHeight1 = sysInfo.windowHeight + 'px'//除标题栏栏外的屏幕可用高度
  101. },
  102. onShow(){
  103. this.listServiceObject()
  104. this.equityCardList()
  105. },
  106. methods: {
  107. goTermsOfService() {
  108. uni.navigateTo({
  109. url: '/myPages/TermsOfService/index?name=' + '娇骄儿权益服务协议' + '&type=' + 4
  110. })
  111. },
  112. selectChange() {
  113. this.selectIcon = !this.selectIcon
  114. },
  115. commonGeneralOrder() {
  116. let promotionParam = uni.getStorageSync('promotionParam')
  117. this.$refs.popup.close()
  118. this.$api.commonGeneralOrder({
  119. ...promotionParam,
  120. orderType: 5,
  121. serviceObjectId: this.serviceObject.id,
  122. equityCardId: this.orderRights.id
  123. }).then(res => {
  124. this.orderNo = res.data.data.orderNo
  125. if (this.curServiceTab === 1) {
  126. //开启余额支付
  127. this.balancePay()
  128. }
  129. if (this.curServiceTab === 2) {
  130. //调微信支付
  131. this.wechatPay()
  132. }
  133. })
  134. },
  135. //余额支付
  136. balancePay() {
  137. let that = this;
  138. this.$api.balancePay({
  139. orderNo: this.orderNo,
  140. password: ''
  141. }).then((res) => {
  142. uni.showToast({
  143. title: '支付成功!'
  144. });
  145. this.getUserInfo()
  146. })
  147. },
  148. wechatPay() {
  149. let that = this;
  150. // 发起微信支付
  151. this.$api.wechatPay({
  152. orderNo: this.orderNo
  153. }).then((res) => {
  154. var param = res.data.data;
  155. uni.requestPayment({
  156. appId: param.appid,
  157. timeStamp: param.timestamp + "",
  158. nonceStr: param.noncestr,
  159. package: "prepay_id=" + param.prepayid,
  160. signType: "RSA",
  161. paySign: param.sign,
  162. success: res => {
  163. uni.showToast({
  164. title: '支付成功!'
  165. });
  166. setTimeout(() => {
  167. uni.navigateTo({
  168. url: '/storePages/myRights/index'
  169. });
  170. }, 2000)
  171. },
  172. fail: res => {
  173. console.log(res)
  174. uni.showModal({
  175. content: '支付失败',
  176. showCancel: false
  177. });
  178. }
  179. });
  180. })
  181. },
  182. getUserInfo() {
  183. this.$api.getUserInfo().then(res => {
  184. console.log('++++++++++++获取用户信息++++++++++++++++++', res)
  185. uni.setStorageSync('userInfo', res.data.data)
  186. this.userInfo = res.data.data
  187. })
  188. },
  189. confirm(e) {
  190. console.log(e)
  191. this.serviceObject = e.value[0]
  192. this.show = false
  193. this.$refs.popup.open()
  194. },
  195. equityCardList() {
  196. this.$api.equityCardList().then(res => {
  197. console.log(res)
  198. this.equityList = res.data.data
  199. })
  200. },
  201. // 查询服务对像信息列表
  202. listServiceObject() {
  203. let serviceObjectList = []
  204. this.$api.listServiceObject(this.reqParm).then((res) => {
  205. res.data.data.forEach(i => {
  206. if (i.isSelf != 1) {
  207. serviceObjectList.push(i)
  208. }
  209. })
  210. this.serviceObjectList[0] = serviceObjectList
  211. })
  212. },
  213. closePayPopup() {
  214. this.$refs.popup.close()
  215. },
  216. payItem(num) {
  217. if (this.userInfo.balance * 1 < this.orderRights.salePrice * 1) {
  218. return
  219. }
  220. this.curServiceTab = num
  221. },
  222. payRights(item) {
  223. this.userInfo = uni.getStorageSync('userInfo')
  224. if (!this.userInfo.phone){
  225. uni.showModal({
  226. title:'温馨提示',
  227. content:'权益卡绑定信息需通过手机号进行获取,是否确认绑定手机号',
  228. success:res=>{
  229. if (res.confirm){
  230. uni.navigateTo({
  231. url: '/myPages/setting/setting-telphone',
  232. })
  233. }
  234. }
  235. })
  236. return
  237. }
  238. if (this.serviceObjectList[0].length === 0) {
  239. uni.showModal({
  240. title: '温馨提示',
  241. content: '默认服务对象不能使用权益卡,是否前往绑定新的服务对象?',
  242. success: res => {
  243. if (res.confirm) {
  244. uni.navigateTo({
  245. url: '/myPages/ServiceObjectManagement/index',
  246. })
  247. }
  248. }
  249. })
  250. return;
  251. }
  252. if (!this.selectIcon) {
  253. uni.$u.toast('请阅读并同意《娇骄儿权益服务协议》')
  254. return;
  255. }
  256. this.show = true
  257. this.orderRights = item
  258. }
  259. },
  260. };
  261. </script>
  262. <style lang="scss" scoped>
  263. @import '/common/css/common.css';
  264. @import './index.rpx.scss';
  265. </style>