index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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="flex-col row-list" v-for="(item, index) in equityList" :key="index">
  14. <view class="flex-row justify-start">
  15. <view class="h-text flex-col justify-center ">
  16. <view class="money">
  17. <text>{{ item.salePrice }}</text>
  18. </view>
  19. <!-- <view class="desc">-->
  20. <!-- <text>{{item.title}}</text>-->
  21. <!-- </view>-->
  22. </view>
  23. <view class="h-center-content flex-col justify-around">
  24. <view class="h-value">
  25. <text>{{ item.title }}</text>
  26. </view>
  27. <view class="title">
  28. 适用项目:{{ item.serviceProjectName || '' }}
  29. </view>
  30. <view class="title">
  31. 适用门店:{{ item.useStoreDesc || '' }}
  32. </view>
  33. <view class="title">
  34. 有效天数:{{ item.effectiveDays }}
  35. </view>
  36. <view class="title flex-row" @click.stop="showRemark(item)">
  37. <text>使用规则</text>
  38. <u-icon v-if="item.id == showRemarkId" name="arrow-down-fill" color="" size="12"></u-icon>
  39. <u-icon v-else name="play-right-fill" color="" size="12"></u-icon>
  40. </view>
  41. </view>
  42. <view class="h-right-content flex-col justify-center ">
  43. <view class="btn" @click="payRights(item)">
  44. <text>购买</text>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-if="showRemarkId == item.id" class="remark" style="text-indent:unset">
  49. <view v-if="item.description !=null">
  50. 使用说明:
  51. <text>{{ item.description }}</text>
  52. </view>
  53. <text v-else class="remarkText">该优惠券暂无使用说明</text>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. </view>
  58. <view class="btnTitle flex-row" v-if="equityList.length > 0">
  59. <u-icon v-if="selectIcon" name="checkmark-circle-fill" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  60. <u-icon v-else name="/static/order/ud9.png" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  61. <text :style="{ 'margin-left': '10rpx' }">请阅读并同意</text>
  62. <text :style="{ 'color': 'red' }" @click="goTermsOfService">《娇骄儿权益服务协议》</text>
  63. </view>
  64. <uni-popup ref="popup" :catchtouchmove="true" :animation="false" type="bottom">
  65. <view class=" payView">
  66. <view class="flex-row justify-between">
  67. <text class="payType">微信支付</text>
  68. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  69. </view>
  70. <view class="payItem flex-row justify-between" @click="payItem(2)">
  71. <view class="flex-row">
  72. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  73. <view class="payName flex-col justify-center">
  74. <text>微信支付</text>
  75. </view>
  76. </view>
  77. <view class="flex-col justify-center">
  78. <view v-if="curServiceTab === 2">
  79. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  80. </view>
  81. <view v-else>
  82. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="commitBtn" @click="commonGeneralOrder">
  87. <text>确定</text>
  88. </view>
  89. </view>
  90. </uni-popup>
  91. <u-picker :show="show" title="选择服务对象" :closeOnClickOverlay="true" @close="show = false" :columns="serviceObjectList"
  92. keyName="nickName" @cancel="show = false" @confirm="confirm"></u-picker>
  93. </view>
  94. </template>
  95. <script>
  96. export default {
  97. data() {
  98. return {
  99. selectIcon: '',
  100. windowHeight: '',
  101. windowHeight1: '',
  102. show: false,
  103. curServiceTab: 2,
  104. orderRights: {},
  105. userInfo: {},
  106. serviceObjectList: [],
  107. serviceObjectIndex: 0,
  108. equityList: [],
  109. serviceObject: {},
  110. orderNo: '',
  111. showRemarkId: '',
  112. };
  113. },
  114. onLoad(option) {
  115. let sysInfo = uni.getSystemInfoSync()
  116. this.windowHeight = sysInfo.windowHeight - 50 + 'px'//除标题栏栏外的屏幕可用高度
  117. this.windowHeight1 = sysInfo.windowHeight + 'px'//除标题栏栏外的屏幕可用高度
  118. },
  119. onShow(){
  120. this.userInfo = uni.getStorageSync('userInfo')
  121. this.listServiceObject()
  122. this.equityCardList()
  123. },
  124. methods: {
  125. showRemark(item) {
  126. if (this.showRemarkId == item.id) {
  127. this.showRemarkId = ''
  128. } else {
  129. this.showRemarkId = item.id
  130. }
  131. },
  132. goTermsOfService() {
  133. uni.navigateTo({
  134. url: '/myPages/TermsOfService/index?name=' + '娇骄儿权益服务协议' + '&type=' + 4
  135. })
  136. },
  137. selectChange() {
  138. this.selectIcon = !this.selectIcon
  139. },
  140. commonGeneralOrder() {
  141. let promotionParam = uni.getStorageSync('promotionParam')
  142. this.$refs.popup.close()
  143. this.$api.commonGeneralOrder({
  144. ...promotionParam,
  145. orderType: 5,
  146. serviceObjectId: this.serviceObject.id,
  147. equityCardId: this.orderRights.id
  148. }).then(res => {
  149. this.orderNo = res.data.data.orderNo
  150. if (this.curServiceTab === 1) {
  151. //开启余额支付
  152. this.balancePay()
  153. }
  154. if (this.curServiceTab === 2) {
  155. //调微信支付
  156. this.wechatPay()
  157. }
  158. })
  159. },
  160. //余额支付
  161. balancePay() {
  162. let that = this;
  163. this.$api.balancePay({
  164. orderNo: this.orderNo,
  165. password: ''
  166. }).then((res) => {
  167. uni.showToast({
  168. title: '支付成功!'
  169. });
  170. this.getUserInfo()
  171. })
  172. },
  173. wechatPay() {
  174. let that = this;
  175. // 发起微信支付
  176. this.$api.wechatPay({
  177. orderNo: this.orderNo
  178. }).then((res) => {
  179. var param = res.data.data;
  180. uni.requestPayment({
  181. appId: param.appid,
  182. timeStamp: param.timestamp + "",
  183. nonceStr: param.noncestr,
  184. package: "prepay_id=" + param.prepayid,
  185. signType: "RSA",
  186. paySign: param.sign,
  187. success: res => {
  188. uni.showToast({
  189. title: '支付成功!'
  190. });
  191. setTimeout(() => {
  192. uni.navigateTo({
  193. url: '/storePages/myRights/index'
  194. });
  195. }, 2000)
  196. },
  197. fail: res => {
  198. console.log(res)
  199. uni.showModal({
  200. content: '支付失败',
  201. showCancel: false
  202. });
  203. }
  204. });
  205. })
  206. },
  207. getUserInfo() {
  208. this.$api.getUserInfo().then(res => {
  209. console.log('++++++++++++获取用户信息++++++++++++++++++', res)
  210. uni.setStorageSync('userInfo', res.data.data)
  211. this.userInfo = res.data.data
  212. })
  213. },
  214. confirm(e) {
  215. console.log(e)
  216. this.serviceObject = e.value[0]
  217. this.show = false
  218. this.$refs.popup.open()
  219. },
  220. equityCardList() {
  221. this.$api.equityCardList().then(res => {
  222. console.log(res)
  223. this.equityList = res.data.data
  224. })
  225. },
  226. // 查询服务对像信息列表
  227. listServiceObject() {
  228. let serviceObjectList = []
  229. this.$api.listServiceObject(this.reqParm).then((res) => {
  230. res.data.data.forEach(i => {
  231. if (i.isSelf != 1) {
  232. serviceObjectList.push(i)
  233. }
  234. })
  235. this.serviceObjectList[0] = serviceObjectList
  236. })
  237. },
  238. closePayPopup() {
  239. this.$refs.popup.close()
  240. },
  241. payItem(num) {
  242. if (this.userInfo.balance * 1 < this.orderRights.salePrice * 1) {
  243. return
  244. }
  245. this.curServiceTab = num
  246. },
  247. payRights(item) {
  248. this.userInfo = uni.getStorageSync('userInfo')
  249. if (!this.userInfo.phone){
  250. uni.showModal({
  251. title:'温馨提示',
  252. content:'权益卡绑定信息需通过手机号进行获取,是否确认绑定手机号',
  253. success:res=>{
  254. if (res.confirm){
  255. uni.navigateTo({
  256. url: '/myPages/setting/setting-telphone',
  257. })
  258. }
  259. }
  260. })
  261. return
  262. }
  263. if (this.serviceObjectList[0].length === 0) {
  264. uni.showModal({
  265. title: '温馨提示',
  266. content: '默认服务对象不能使用权益卡,是否前往绑定新的服务对象?',
  267. success: res => {
  268. if (res.confirm) {
  269. uni.navigateTo({
  270. url: '/myPages/ServiceObjectManagement/index',
  271. })
  272. }
  273. }
  274. })
  275. return;
  276. }
  277. if (!this.selectIcon) {
  278. uni.$u.toast('请阅读并同意《娇骄儿权益服务协议》')
  279. return;
  280. }
  281. this.show = true
  282. this.orderRights = item
  283. }
  284. },
  285. };
  286. </script>
  287. <style lang="scss" scoped>
  288. @import '/common/css/common.css';
  289. @import './index.rpx.scss';
  290. </style>