openMember.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <view class="content">
  3. <view class="card-list">
  4. <view class="card-label">{{memberInfo.typeValue}}</view>
  5. <view class="card-num">¥{{memberInfo.originalAmount}}</view>
  6. <view class="card-icon iconfont iconzu4931"></view>
  7. </view>
  8. <u-cell-group style="width: 100%; float: left;">
  9. <u-cell-item title="使用时间" :value="memberInfo.startDate + '~' + memberInfo.endDate" :arrow="false"></u-cell-item>
  10. <u-cell-item title="优惠金额" :value="couponId ? '-¥' + memberInfo.discountsAmount : ''" @click="couponShow = true"></u-cell-item>
  11. <u-cell-item title="学员姓名" :value="studentName" @click="studentShow = true" required></u-cell-item>
  12. <u-cell-item title="实际金额" :value="'¥' + memberInfo.realPayAmount" :arrow="false"></u-cell-item>
  13. <!-- <u-cell-item title="乙方签字" :arrow="false" :title-style="{width: '100%'}" required>
  14. <view class="canvas-container" slot="label">
  15. <canvas canvas-id="canvas" id="canvas" :disable-scroll="true" v-show="!couponShow && !studentShow" style="width: 100%; height: 200px;background-color: #FFFFFF;"
  16. @touchstart="handleTouchStart($event)" @touchmove="handleTouchMove($event)" @touchend="handleTouchEnd($event)"
  17. @touchcancel="handleEnd($event)"></canvas>
  18. </view>
  19. </u-cell-item> -->
  20. </u-cell-group>
  21. <u-popup v-model="couponShow" mode="bottom" border-radius="30" closeable>
  22. <scroll-view scroll-y style="height:300px;margin: 30px 0 15px 0;">
  23. <u-card :show-head="false" :show-foot="false" padding="0px" margin="0px 30px 20px 30px" borderRadius="40" v-for="(item, index) in couponList"
  24. :key="index" class="class-card" @click="selectCoupon(item)">
  25. <view class="class-content" slot="body">
  26. <view class="class-info-img">
  27. <u-image width="60px" height="60px" :src="item.url" shape="circle"></u-image>
  28. </view>
  29. <view class="class-info-content">
  30. <view class="class-info-label">{{item.name}}¥{{item.amount}}</view>
  31. <view class="class-info-text">{{item.typeValue}}&nbsp;&nbsp;{{item.content}}</view>
  32. <view class="class-info-text">{{item.endDate}}&nbsp;&nbsp;到期</view>
  33. </view>
  34. </view>
  35. </u-card>
  36. </scroll-view>
  37. </u-popup>
  38. <view class="handle-fix-box">
  39. <!-- <text class="contract-link" @click="checkContract()">点击查看合同协议</text> -->
  40. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="toPay()">确定支付¥{{memberInfo.realPayAmount}}</u-button>
  41. </view>
  42. <u-popup v-model="studentShow" mode="bottom" border-radius="30">
  43. <scroll-view scroll-y class="student-box">
  44. <u-card :title="item.studentName" title-size="32" :head-style="cardStyle" :head-border-bottom="false" :show-foot="false"
  45. margin="10px" borderRadius="20" v-for="(item, index) in studentList" :key="index" @click="selectStudent(item)">
  46. <view class="student-card" slot="body">
  47. <view class="class-info-text">性别:{{item.sex}}&nbsp;&nbsp;年龄:{{item.age}}</view>
  48. </view>
  49. </u-card>
  50. </scroll-view>
  51. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,margin:'15px',float: 'left',width: 'calc(100% - 30px)'}"
  52. @click="goToSubscribelForm()">新增学员</u-button>
  53. </u-popup>
  54. <u-top-tips ref="uTips"></u-top-tips>
  55. </view>
  56. </template>
  57. <script>
  58. var context = null
  59. import {
  60. mapGetters
  61. } from 'vuex'
  62. const NET = require('@/utils/request')
  63. const API = require('@/config/api')
  64. export default {
  65. computed: {
  66. ...mapGetters([
  67. 'mainColor',
  68. 'customStyle',
  69. ])
  70. },
  71. data() {
  72. return {
  73. memberCardId: '',
  74. memberInfo: {
  75. originalAmount: '',
  76. discountsAmount: '',
  77. realPayAmount: '',
  78. typeValue: '',
  79. endDate: '',
  80. startDate: '',
  81. },
  82. couponId: '',
  83. couponShow: false,
  84. couponList: [],
  85. cardStyle: {
  86. fontWeight: 'bold'
  87. },
  88. studentId: '',
  89. studentName: '',
  90. studentShow: false,
  91. studentList: [],
  92. contractInfo: {
  93. id: '',
  94. url: '',
  95. },
  96. canvasData: [],
  97. signUrl: ''
  98. }
  99. },
  100. watch: {
  101. canvasData() {
  102. context.moveTo(this.canvasData[0].x, this.canvasData[0].y)
  103. for (let i = 0; i < this.canvasData.length; i++) {
  104. context.lineTo(this.canvasData[i].x, this.canvasData[i].y)
  105. }
  106. context.stroke()
  107. context.draw(true)
  108. }
  109. },
  110. onLoad(options) {
  111. this.memberCardId = options.id
  112. this.getMemberInfo()
  113. context = uni.createCanvasContext('canvas')
  114. context.setLineWidth(3)
  115. context.setStrokeStyle("#000000")
  116. this.reset()
  117. },
  118. onShow() {
  119. NET.request(API.getAllStudentList, {}, 'POST').then(res => {
  120. this.studentList = res.data
  121. }).catch(error => {
  122. this.$refs.uTips.show({
  123. title: error.message,
  124. type: 'warning',
  125. })
  126. })
  127. },
  128. methods: {
  129. // 获取数据
  130. getMemberInfo() {
  131. NET.request(API.getMemberCardInfo, {
  132. id: this.memberCardId
  133. }, 'POST').then(res => {
  134. this.memberInfo = res.data
  135. }).catch(error => {
  136. this.$refs.uTips.show({
  137. title: error.message,
  138. type: 'warning',
  139. })
  140. })
  141. NET.request(API.getUsableCouponList, {
  142. id: this.memberCardId
  143. }, 'POST').then(res => {
  144. this.couponList = res.data.row
  145. }).catch(error => {
  146. this.$refs.uTips.show({
  147. title: error.message,
  148. type: 'warning',
  149. })
  150. })
  151. NET.request(API.getContractInfo, {
  152. cardId: this.memberCardId
  153. }, 'POST').then(res => {
  154. this.contractInfo = res.data
  155. }).catch(error => {
  156. this.$refs.uTips.show({
  157. title: error.message,
  158. type: 'warning',
  159. })
  160. })
  161. },
  162. // 更新数据
  163. refreshMemberInfo() {
  164. NET.request(API.getMemberCardInfoAfterCoupon, {
  165. memberId: this.memberCardId,
  166. couponId: this.couponId,
  167. studentId: this.studentId
  168. }, 'POST').then(res => {
  169. this.memberInfo = res.data
  170. this.couponShow = false
  171. this.studentShow = false
  172. }).catch(error => {
  173. this.$refs.uTips.show({
  174. title: error.message,
  175. type: 'warning',
  176. })
  177. })
  178. },
  179. // 选择优惠券
  180. selectCoupon(item) {
  181. this.couponId = item.id
  182. this.refreshMemberInfo()
  183. },
  184. // 选择学员
  185. selectStudent(item) {
  186. this.studentId = item.studentId
  187. this.studentName = item.studentName
  188. this.refreshMemberInfo()
  189. },
  190. // 显示合同
  191. checkContract() {
  192. uni.downloadFile({
  193. url: this.contractInfo.url,
  194. success: (res) => {
  195. uni.openDocument({
  196. filePath: res.tempFilePath,
  197. });
  198. }
  199. })
  200. },
  201. // 重置
  202. reset() {
  203. context.draw()
  204. },
  205. // 签字版触屏开始
  206. handleTouchStart(e) {
  207. if (!this.studentShow && !this.couponShow) {
  208. const a = e.changedTouches[0]
  209. this.canvasData.push({
  210. x: a.x,
  211. y: a.y
  212. })
  213. }
  214. this.canvasData = []
  215. },
  216. // 签字版触屏移动
  217. handleTouchMove(e) {
  218. if (!this.studentShow && !this.couponShow) {
  219. const a = e.changedTouches[0]
  220. this.canvasData.push({
  221. x: a.x,
  222. y: a.y
  223. })
  224. }
  225. },
  226. // 签字版触屏结束
  227. handleTouchEnd(e) {
  228. if (!this.studentShow && !this.couponShow) {
  229. const a = e.changedTouches[0]
  230. this.canvasData.push({
  231. x: a.x,
  232. y: a.y
  233. })
  234. }
  235. },
  236. handleEnd() {
  237. if (!this.studentShow && !this.couponShow) {
  238. context.stroke()
  239. context.draw(true)
  240. }
  241. },
  242. // 提交签字
  243. submitContract() {
  244. if (!this.studentId) {
  245. this.$refs.uTips.show({
  246. title: '请选择学员',
  247. type: 'warning',
  248. })
  249. return
  250. }
  251. let that = this
  252. uni.canvasToTempFilePath({
  253. canvasId: 'canvas',
  254. success: res => {
  255. uni.uploadFile({
  256. url: API.uploadFile,
  257. filePath: res.tempFilePath,
  258. name: 'file',
  259. header: {
  260. Authorization: uni.getStorageSync('token')
  261. },
  262. success: (uploadFileRes) => {
  263. that.signUrl = JSON.parse(uploadFileRes.data).data.id
  264. NET.request(API.submitContractForm, {
  265. contractId: that.contractInfo.id,
  266. fileId: that.signUrl,
  267. }, 'POST').then(res => {
  268. that.toPay(res.data.id)
  269. }).catch(error => {
  270. that.$refs.uTips.show({
  271. title: error.message,
  272. type: 'warning',
  273. })
  274. })
  275. }
  276. });
  277. }
  278. })
  279. },
  280. // 支付
  281. toPay(contractId) {
  282. if (!this.studentId) {
  283. this.$refs.uTips.show({
  284. title: '请选择学员',
  285. type: 'warning',
  286. })
  287. return
  288. }
  289. // NET.request(API.getPayParams, {
  290. // id: this.memberCardId,
  291. // couponId: this.couponId,
  292. // studentId: this.studentId,
  293. // contractId: contractId
  294. // }, 'POST').then(res => {
  295. // if (this.memberInfo.realPayAmount <= 0) {
  296. // this.goToPayResult(res.data.oderNo)
  297. // return false
  298. // }
  299. // uni.requestPayment({
  300. // provider: 'wxpay',
  301. // timeStamp: res.data.timeStamp,
  302. // nonceStr: res.data.nonceStr,
  303. // package: res.data.packageString,
  304. // signType: res.data.signType,
  305. // paySign: res.data.paySign,
  306. // success: (payRes) => {
  307. // this.goToPayResult(res.data.oderNo)
  308. // },
  309. // fail: (error) => {
  310. // this.$refs.uTips.show({
  311. // title: '支付未成功',
  312. // type: 'warning',
  313. // })
  314. // }
  315. // })
  316. // }).catch(error => {
  317. // this.$refs.uTips.show({
  318. // title: error.message,
  319. // type: 'warning',
  320. // })
  321. // })
  322. uni.navigateTo({
  323. url: '/pagesMain/contractInfo?memberCardId=' + this.memberCardId + '&couponId=' + this.couponId + '&studentId=' +
  324. this.studentId + '&realPayAmount=' + this.memberInfo.realPayAmount
  325. });
  326. },
  327. // 跳转支付结果
  328. goToPayResult(oderNo) {
  329. uni.redirectTo({
  330. url: '/pagesMain/payResult?id=' + oderNo
  331. });
  332. },
  333. // 跳转新增学员表单
  334. goToSubscribelForm() {
  335. uni.navigateTo({
  336. url: '/pagesMember/subscribelForm'
  337. });
  338. },
  339. },
  340. }
  341. </script>
  342. <style>
  343. page {
  344. width: 100%;
  345. height: 100%;
  346. }
  347. </style>
  348. <style lang="scss" scoped>
  349. @import "@/static/css/themes.scss";
  350. .content {
  351. width: 100%;
  352. float: left;
  353. // padding: 15px 15px 85px 15px;
  354. padding: 15px 15px 60px 15px;
  355. box-sizing: border-box;
  356. .card-list {
  357. width: 100%;
  358. padding: 15px 20px;
  359. margin-bottom: 15px;
  360. float: left;
  361. background-color: #FFFFFF;
  362. border-radius: 15px;
  363. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  364. position: relative;
  365. overflow: hidden;
  366. .card-label {
  367. width: 100%;
  368. margin-bottom: 10px;
  369. float: left;
  370. font-size: 18px;
  371. font-weight: bold;
  372. line-height: 20px;
  373. }
  374. .card-num {
  375. width: 100%;
  376. float: left;
  377. font-size: 28px;
  378. line-height: 28px;
  379. color: $mainColor;
  380. }
  381. .card-icon {
  382. font-size: 80px;
  383. color: $mainColor;
  384. position: absolute;
  385. right: -15px;
  386. bottom: -15x;
  387. opacity: 0.5;
  388. }
  389. }
  390. .class-card {
  391. .class-content {
  392. padding: 10px 15px;
  393. display: flex;
  394. align-items: center;
  395. position: relative;
  396. }
  397. .class-info-img {
  398. width: 60px;
  399. height: 60px;
  400. margin-right: 10px;
  401. }
  402. .class-info-content {
  403. flex: 1;
  404. }
  405. .class-info-label {
  406. font-size: 16px;
  407. color: #000000;
  408. word-break: break-all;
  409. }
  410. .class-info-text {
  411. color: #999999;
  412. margin-bottom: 5px;
  413. }
  414. }
  415. .student-box {
  416. max-height: 200px;
  417. padding: 0 15px;
  418. margin: 25px 0 0 0;
  419. box-sizing: border-box;
  420. overflow: auto;
  421. /deep/.u-card__head {
  422. padding-bottom: 0px !important;
  423. }
  424. }
  425. .canvas-container {
  426. width: 100%;
  427. height: 200px;
  428. }
  429. .handle-fix-box {
  430. // height: 85px;
  431. height: 60px;
  432. text-align: center;
  433. .contract-link {
  434. color: $mainColor;
  435. line-height: 25px;
  436. }
  437. }
  438. }
  439. </style>