index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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 param = uni.getStorageSync('promotionParam')
  142. console.log('获取到技师的二维码数据',param)
  143. if (!param){
  144. console.log('获取到门店的二维码数据',param)
  145. param = uni.getStorageSync('storeParam')
  146. }
  147. this.$refs.popup.close()
  148. this.$api.commonGeneralOrder({
  149. ...param,
  150. orderType: 5,
  151. serviceObjectId: this.serviceObject.id,
  152. equityCardId: this.orderRights.id
  153. }).then(res => {
  154. this.orderNo = res.data.data.orderNo
  155. if (this.curServiceTab === 1) {
  156. //开启余额支付
  157. this.balancePay()
  158. }
  159. if (this.curServiceTab === 2) {
  160. //调微信支付
  161. this.wechatPay()
  162. }
  163. })
  164. },
  165. //余额支付
  166. balancePay() {
  167. let that = this;
  168. this.$api.balancePay({
  169. orderNo: this.orderNo,
  170. password: ''
  171. }).then((res) => {
  172. uni.showToast({
  173. title: '支付成功!'
  174. });
  175. this.getUserInfo()
  176. })
  177. },
  178. wechatPay() {
  179. let that = this;
  180. // 发起微信支付
  181. this.$api.wechatPay({
  182. orderNo: this.orderNo
  183. }).then((res) => {
  184. var param = res.data.data;
  185. uni.requestPayment({
  186. appId: param.appid,
  187. timeStamp: param.timestamp + "",
  188. nonceStr: param.noncestr,
  189. package: "prepay_id=" + param.prepayid,
  190. signType: "RSA",
  191. paySign: param.sign,
  192. success: res => {
  193. uni.showToast({
  194. title: '支付成功!'
  195. });
  196. setTimeout(() => {
  197. uni.navigateTo({
  198. url: '/storePages/myRights/index'
  199. });
  200. }, 2000)
  201. },
  202. fail: res => {
  203. console.log(res)
  204. uni.showModal({
  205. content: '支付失败',
  206. showCancel: false
  207. });
  208. }
  209. });
  210. })
  211. },
  212. getUserInfo() {
  213. this.$api.getUserInfo().then(res => {
  214. console.log('++++++++++++获取用户信息++++++++++++++++++', res)
  215. uni.setStorageSync('userInfo', res.data.data)
  216. this.userInfo = res.data.data
  217. })
  218. },
  219. confirm(e) {
  220. console.log(e)
  221. this.serviceObject = e.value[0]
  222. this.show = false
  223. this.$refs.popup.open()
  224. },
  225. equityCardList() {
  226. this.$api.equityCardList().then(res => {
  227. console.log(res)
  228. this.equityList = res.data.data
  229. })
  230. },
  231. // 查询服务对像信息列表
  232. listServiceObject() {
  233. let serviceObjectList = []
  234. this.$api.listServiceObject(this.reqParm).then((res) => {
  235. res.data.data.forEach(i => {
  236. if (i.isSelf != 1) {
  237. serviceObjectList.push(i)
  238. }
  239. })
  240. this.serviceObjectList[0] = serviceObjectList
  241. })
  242. },
  243. closePayPopup() {
  244. this.$refs.popup.close()
  245. },
  246. payItem(num) {
  247. if (this.userInfo.balance * 1 < this.orderRights.salePrice * 1) {
  248. return
  249. }
  250. this.curServiceTab = num
  251. },
  252. payRights(item) {
  253. this.userInfo = uni.getStorageSync('userInfo')
  254. if (!this.userInfo.phone){
  255. uni.showModal({
  256. title:'温馨提示',
  257. content:'权益卡绑定信息需通过手机号进行获取,是否确认绑定手机号',
  258. success:res=>{
  259. if (res.confirm){
  260. uni.navigateTo({
  261. url: '/myPages/setting/setting-telphone',
  262. })
  263. }
  264. }
  265. })
  266. return
  267. }
  268. if (this.serviceObjectList[0].length === 0) {
  269. uni.showModal({
  270. title: '温馨提示',
  271. content: '默认服务对象不能使用权益卡,是否前往绑定新的服务对象?',
  272. success: res => {
  273. if (res.confirm) {
  274. uni.navigateTo({
  275. url: '/myPages/ServiceObjectManagement/index',
  276. })
  277. }
  278. }
  279. })
  280. return;
  281. }
  282. if (!this.selectIcon) {
  283. uni.$u.toast('请阅读并同意《娇骄儿权益服务协议》')
  284. return;
  285. }
  286. this.show = true
  287. this.orderRights = item
  288. }
  289. },
  290. };
  291. </script>
  292. <style lang="scss" scoped>
  293. @import '/common/css/common.css';
  294. @import './index.rpx.scss';
  295. </style>