transfer.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div class="page">
  3. <van-nav-bar
  4. :title="title"
  5. left-text="返回"
  6. left-arrow
  7. @click-left="onClickLeft"
  8. ></van-nav-bar>
  9. <div class="transferTop">
  10. <p>{{ transferInfo.dealAmount }}套</p>
  11. <span>课程名额</span>
  12. </div>
  13. <div class="transferConetent">
  14. <span>{{ transferInfo.name }}</span>
  15. <courseList :dataList="courseInfo" :showNum="3"></courseList>
  16. <p>备注信息:{{ transferInfo.content }}</p>
  17. </div>
  18. <div class="transferBtm">
  19. <van-button
  20. style="padding:0 .5rem;"
  21. type="primary"
  22. v-if="transferInfo.toUserId == user_info.id"
  23. @click="confirm"
  24. >确认接收</van-button
  25. >
  26. <van-button
  27. style="padding:0 .5rem;background-color: #999;color:#FFF;"
  28. size="large"
  29. v-else
  30. >等待对方接收</van-button
  31. >
  32. <div class="transferTH">
  33. <p>如一天内未确认,将自动退还对方。 <span @click="returnLimit()">{{user_info.id == transferInfo.toUserId?'立即退还':'立即撤回'}}</span></p>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import {dealAccept,dealRefund,dealRecall} from '../api'
  40. import courseList from "../components/courseList.vue";
  41. export default {
  42. name: "courseTransfer",
  43. components: { courseList },
  44. props: [],
  45. data() {
  46. return {
  47. title: "课程交易",
  48. transferInfo: {},
  49. user_info:JSON.parse(localStorage.getItem('wx_user_info'))
  50. };
  51. },
  52. computed: {
  53. courseInfo() {
  54. let list = [];
  55. list.push(this.transferInfo);
  56. console.log(list);
  57. return list;
  58. }
  59. },
  60. created() {
  61. this.init()
  62. },
  63. methods: {
  64. init(){
  65. this.transferInfo = this.$route.query
  66. console.log(this.transferInfo)
  67. },
  68. onClickLeft() {
  69. this.$router.go(-1);
  70. },
  71. returnLimit(){
  72. if(this.transferInfo.toUserId == this.user_info.id){
  73. this.$dialog.confirm({
  74. title: "提示",
  75. message: "确认退还当前转让的名额?"
  76. })
  77. .then(() => {
  78. this.sendback();
  79. })
  80. .catch(() => {
  81. });
  82. }else{
  83. this.$dialog.confirm({
  84. title: "提示",
  85. message: "确认撤回当前转让的名额?"
  86. })
  87. .then(() => {
  88. this.sendRecall()
  89. })
  90. .catch(() => {
  91. });
  92. }
  93. },
  94. // 退还名额
  95. sendback(){
  96. let data = {
  97. transferId:this.transferInfo.id,
  98. subjectId:this.transferInfo.subjectId,
  99. toUserId:this.transferInfo.toUserId,
  100. fromUserId:this.transferInfo.fromUserId,
  101. }
  102. dealRefund(data).then(res=>{
  103. this.$toast.success('退回成功')
  104. setTimeout(()=>{
  105. this.$router.go(-1)
  106. })
  107. })
  108. },
  109. // 撤回名额
  110. sendRecall(){
  111. let data = {
  112. transferId:this.transferInfo.id,
  113. subjectId:this.transferInfo.subjectId,
  114. toUserId:this.transferInfo.toUserId,
  115. fromUserId:this.transferInfo.fromUserId,
  116. }
  117. dealRecall(data).then(res=>{
  118. this.$toast.success('退回成功')
  119. setTimeout(()=>{
  120. this.$router.go(-1)
  121. })
  122. })
  123. },
  124. // 接收名额
  125. acceptAccount(){
  126. let data = {
  127. transferId:this.transferInfo.id,
  128. subjectId:this.transferInfo.subjectId,
  129. toUserId:this.transferInfo.toUserId,
  130. fromUserId:this.transferInfo.fromUserId,
  131. }
  132. dealAccept(data).then(res=>{
  133. this.$toast.success('接收成功')
  134. setTimeout(()=>{
  135. this.$router.go(-1)
  136. })
  137. })
  138. },
  139. confirm() {
  140. this.$dialog.confirm({
  141. title: "提示",
  142. message: "确认接收当前转让的名额?"
  143. })
  144. .then(() => {
  145. this.acceptAccount()
  146. })
  147. .catch(() => {
  148. // on cancel
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style scoped lang="scss">
  155. * {
  156. margin: 0;
  157. padding: 0;
  158. }
  159. img {
  160. display: block;
  161. }
  162. .page {
  163. position: relative;
  164. .transferTop {
  165. padding: 0.6rem;
  166. text-align: center;
  167. p {
  168. font-size: 0.6rem;
  169. color: #000;
  170. }
  171. span {
  172. font-size: 0.3rem;
  173. line-height: 2;
  174. }
  175. }
  176. .transferConetent {
  177. .listOuer {
  178. padding: 0 0 0.1rem;
  179. background-color: #fff;
  180. }
  181. & > span {
  182. margin-left: 0.2rem;
  183. font-size: 0.26rem;
  184. color: #666;
  185. line-height: 1.4;
  186. }
  187. & > p {
  188. font-size: 0.28rem;
  189. color: #333;
  190. line-height: 1.3;
  191. padding: 0 0.2rem;
  192. }
  193. }
  194. .transferBtm {
  195. display: flex;
  196. flex-wrap: wrap;
  197. justify-content: center;
  198. padding-top: 0.7rem;
  199. .transferTH {
  200. margin-top: 0.7rem;
  201. width: 100%;
  202. display: flex;
  203. justify-content: center;
  204. p {
  205. font-size: 0.26rem;
  206. color: #000;
  207. }
  208. span {
  209. color: #26a2ff;
  210. }
  211. }
  212. }
  213. }
  214. </style>