index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. <uni-popup ref="selectObjectPopup" type="bottom">
  94. <view class="addService">
  95. <view class="popupTitle">
  96. <text>选择服务对象</text>
  97. </view>
  98. <scroll-view class="scrollY" scroll-y>
  99. <view class="flex-row objectItem" :class="{'vBackGround': selectServiceObjectIndex === index}"
  100. v-for="(item,index) in serviceObjectList" :key="index"
  101. @click="selectServiceObjectIndex = index">
  102. <image class="objectImage" :src="item.facePhotoUrl || '/static/ud4.png'"></image>
  103. <view class="flex-col objectName ">
  104. <text>{{ item.nickName }}</text>
  105. </view>
  106. <image v-if="selectServiceObjectIndex === index" class="vImage"
  107. src="/static/index/xuanzhong.png"></image>
  108. </view>
  109. </scroll-view>
  110. <view class="flex-row justify-around">
  111. <view class="cancelButton" @click="closeSelectServiceObjectPopup">
  112. <text>取消</text>
  113. </view>
  114. <view class="confirmButton" @click="confirm(serviceObjectList[selectServiceObjectIndex])">
  115. <text>确定</text>
  116. </view>
  117. </view>
  118. </view>
  119. </uni-popup>
  120. </view>
  121. </template>
  122. <script>
  123. export default {
  124. data() {
  125. return {
  126. selectServiceObjectIndex:-1,
  127. selectIcon: '',
  128. windowHeight: '',
  129. windowHeight1: '',
  130. show: false,
  131. curServiceTab: 2,
  132. orderRights: {},
  133. userInfo: {},
  134. serviceObjectList: [],
  135. serviceObjectIndex: 0,
  136. equityList: [],
  137. serviceObject: {},
  138. orderNo: '',
  139. showRemarkId: '',
  140. };
  141. },
  142. onLoad(option) {
  143. let sysInfo = uni.getSystemInfoSync()
  144. this.windowHeight = sysInfo.windowHeight - 50 + 'px'//除标题栏栏外的屏幕可用高度
  145. this.windowHeight1 = sysInfo.windowHeight + 'px'//除标题栏栏外的屏幕可用高度
  146. },
  147. onShow() {
  148. this.userInfo = uni.getStorageSync('userInfo')
  149. this.listServiceObject()
  150. this.equityCardList()
  151. },
  152. methods: {
  153. showRemark(item) {
  154. if (this.showRemarkId == item.id) {
  155. this.showRemarkId = ''
  156. } else {
  157. this.showRemarkId = item.id
  158. }
  159. },
  160. goTermsOfService() {
  161. uni.navigateTo({
  162. url: '/myPages/TermsOfService/index?name=' + '娇骄儿权益服务协议' + '&type=' + 4
  163. })
  164. },
  165. closeSelectServiceObjectPopup(){
  166. this.selectServiceObjectIndex = -1
  167. this.$refs.selectObjectPopup.close()
  168. },
  169. selectChange() {
  170. this.selectIcon = !this.selectIcon
  171. },
  172. getImgUrlByBannerOssId(items) {
  173. for (let i = 0; i < items.length; i++) {
  174. if (items[i].facePhoto) {
  175. this.$api.getImgUrlByOssId({ossId: items[i].facePhoto}).then(res => {
  176. items[i].facePhotoUrl = res.data.data[0].url.replace(/^http:/, "https:")
  177. this.$set(this.serviceObjectList, i, items[i])
  178. })
  179. }
  180. }
  181. },
  182. commonGeneralOrder() {
  183. let param = uni.getStorageSync('promotionParam')
  184. console.log('获取到技师的二维码数据', param)
  185. if (!param) {
  186. console.log('获取到门店的二维码数据', param)
  187. param = uni.getStorageSync('storeParam')
  188. }
  189. this.$refs.popup.close()
  190. this.$api.commonGeneralOrder({
  191. ...param,
  192. orderType: 5,
  193. serviceObjectId: this.serviceObject.id,
  194. equityCardId: this.orderRights.id
  195. }).then(res => {
  196. this.orderNo = res.data.data.orderNo
  197. if (this.curServiceTab === 1) {
  198. //开启余额支付
  199. this.balancePay()
  200. }
  201. if (this.curServiceTab === 2) {
  202. //调微信支付
  203. this.wechatPay()
  204. }
  205. })
  206. },
  207. //余额支付
  208. balancePay() {
  209. let that = this;
  210. this.$api.balancePay({
  211. orderNo: this.orderNo,
  212. password: ''
  213. }).then((res) => {
  214. uni.showToast({
  215. title: '支付成功!'
  216. });
  217. this.getUserInfo()
  218. })
  219. },
  220. wechatPay() {
  221. let that = this;
  222. // 发起微信支付
  223. this.$api.wechatPay({
  224. orderNo: this.orderNo
  225. }).then((res) => {
  226. var param = res.data.data;
  227. uni.requestPayment({
  228. appId: param.appid,
  229. timeStamp: param.timestamp + "",
  230. nonceStr: param.noncestr,
  231. package: "prepay_id=" + param.prepayid,
  232. signType: "RSA",
  233. paySign: param.sign,
  234. success: res => {
  235. uni.showToast({
  236. title: '支付成功!'
  237. });
  238. setTimeout(() => {
  239. uni.navigateTo({
  240. url: '/storePages/myRights/index'
  241. });
  242. }, 2000)
  243. },
  244. fail: res => {
  245. console.log(res)
  246. uni.showModal({
  247. content: '支付失败',
  248. showCancel: false
  249. });
  250. }
  251. });
  252. })
  253. },
  254. getUserInfo() {
  255. this.$api.getUserInfo().then(res => {
  256. console.log('++++++++++++获取用户信息++++++++++++++++++', res)
  257. uni.setStorageSync('userInfo', res.data.data)
  258. this.userInfo = res.data.data
  259. })
  260. },
  261. confirm(e) {
  262. console.log(e)
  263. if(!e){
  264. uni.showToast({
  265. duration: 2000,
  266. title: '请选择一个服务对象',
  267. icon: 'none'
  268. });
  269. return
  270. }
  271. // this.serviceObject = e.value[0]
  272. this.serviceObject = e
  273. // this.show = false
  274. this.$refs.selectObjectPopup.close()
  275. this.$refs.popup.open()
  276. },
  277. equityCardList() {
  278. this.$api.equityCardList().then(res => {
  279. console.log(res)
  280. this.equityList = res.data.data
  281. })
  282. },
  283. // 查询服务对像信息列表
  284. listServiceObject() {
  285. let serviceObjectList = []
  286. this.$api.listServiceObject(this.reqParm).then((res) => {
  287. res.data.data.forEach(i => {
  288. if (i.isSelf != 1) {
  289. serviceObjectList.push(i)
  290. }
  291. })
  292. this.serviceObjectList[0] = serviceObjectList
  293. this.getImgUrlByBannerOssId(this.serviceObjectList[0]);
  294. })
  295. },
  296. closePayPopup() {
  297. this.$refs.popup.close()
  298. },
  299. payItem(num) {
  300. if (this.userInfo.balance * 1 < this.orderRights.salePrice * 1) {
  301. return
  302. }
  303. this.curServiceTab = num
  304. },
  305. payRights(item) {
  306. this.userInfo = uni.getStorageSync('userInfo')
  307. if (!this.userInfo.phone) {
  308. uni.showModal({
  309. title: '温馨提示',
  310. content: '权益卡绑定信息需通过手机号进行获取,是否确认绑定手机号',
  311. success: res => {
  312. if (res.confirm) {
  313. uni.navigateTo({
  314. url: '/myPages/setting/setting-telphone',
  315. })
  316. }
  317. }
  318. })
  319. return
  320. }
  321. if (this.serviceObjectList[0].length === 0) {
  322. uni.showModal({
  323. title: '温馨提示',
  324. content: '默认服务对象不能使用权益卡,是否前往绑定新的服务对象?',
  325. success: res => {
  326. if (res.confirm) {
  327. uni.navigateTo({
  328. url: '/myPages/ServiceObjectManagement/index',
  329. })
  330. }
  331. }
  332. })
  333. return;
  334. }
  335. if (!this.selectIcon) {
  336. uni.$u.toast('请阅读并同意《娇骄儿权益服务协议》')
  337. return;
  338. }
  339. // this.show = true
  340. this.orderRights = item
  341. this.$refs.selectObjectPopup.open()
  342. }
  343. },
  344. };
  345. </script>
  346. <style lang="scss" scoped>
  347. @import '/common/css/common.css';
  348. @import './index.rpx.scss';
  349. </style>