giftDetail.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div>
  3. <nav-bar path="index" title="礼品卡"/>
  4. <!--对方的礼物信息-->
  5. <gift-card
  6. v-if="myPresent.status === 2 || myPresent.status === 3"
  7. :present-img="recievedPresent.imgUrl"
  8. :present-name="recievedPresent.name"
  9. :present-desc="recievedPresent.desc_long"
  10. :owner="1"
  11. :placeId="recievedPresent.placeId"
  12. :gender="recievedPresent.gender"
  13. :status="recievedPresent.status"
  14. :wechat="recievedPresent.wechat"
  15. />
  16. <!--我写的感谢信-->
  17. <div class="letter" v-if="recievedPresent.comment.length !== 0">
  18. <p style="font-size: 110%"><strong>我送出的感谢信</strong></p>
  19. <p>{{recievedPresent.comment}}</p>
  20. </div>
  21. <!--我的礼物信息-->
  22. <gift-card
  23. :present-img="myPresent.imgUrl"
  24. :present-name="myPresent.name"
  25. :present-desc="myPresent.desc_long"
  26. :owner="0"
  27. :placeId="myPresent.placeId"
  28. :gender="myPresent.gender"
  29. :status="myPresent.status"
  30. :wechat="myPresent.wechat"
  31. />
  32. <div class="letter" v-if="myPresent.comment.length !== 0">
  33. <p style="font-size: 110%"><strong>我收到的感谢信</strong></p>
  34. <p>{{myPresent.comment}}</p>
  35. </div>
  36. <div class="letter" v-if="myPresent.status === 4">
  37. <p><strong>审核未通过,请前往首页重新发布礼物!</strong></p>
  38. <p v-if="reason.length !== 0">原因:{{reason}}</p>
  39. </div>
  40. <div style="height: 100px; width: 100%"></div>
  41. <img src="http://pjczv6ygf.bkt.clouddn.com/present_card_bottom.png"
  42. style="position: fixed; bottom: 100px; max-width: 100%; z-index: -1"
  43. />
  44. <div
  45. v-if="myPresent.status === 2"
  46. style="position: fixed; bottom: 0; width: 100%; background-color: #fff6e3"
  47. >
  48. <van-button
  49. type="primary" size="large"
  50. style="background-color: #fd6740; border-color: #fd6740; width: 85%;"
  51. @click="toWriteComment"
  52. >确认交换成功</van-button>
  53. <p>交换成功可以开始接收对方发来的感谢信哦</p>
  54. </div>
  55. <div
  56. v-if="myPresent.status === 0 || myPresent.status === 1 || myPresent.status === 4"
  57. style="position: fixed; bottom: 0; width: 100%"
  58. >
  59. <van-button
  60. type="default" size="large"
  61. style="width: 85%;"
  62. @click="editPresent"
  63. v-if="myPresent.status !== 4"
  64. >修改礼物</van-button>
  65. <van-button
  66. type="warning" size="large"
  67. style="width: 85%; margin: 10px 0 10px"
  68. @click="deletePresent"
  69. >删除礼物</van-button>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import GiftCard from "../components/giftCard";
  75. import {Button, Dialog, Toast} from 'vant'
  76. import NavBar from "../components/navBar";
  77. import {BasicFunction} from "../connector/basic-service";
  78. export default {
  79. name: "giftDetail",
  80. components: {
  81. NavBar,
  82. GiftCard,
  83. [Button.name]: Button,
  84. },
  85. data() {
  86. return {
  87. myPresent: {
  88. placeId: 1,
  89. comment: '',
  90. },
  91. reason: '',
  92. recievedPresent: {
  93. comment: ''
  94. }
  95. }
  96. },
  97. methods:{
  98. editPresent: function() {
  99. Toast.loading({
  100. mask: true,
  101. message: '加载中...',
  102. duration: 500
  103. });
  104. let p = this.myPresent;
  105. this.$router.push({path: 'presentRegister', query: {present: p}});
  106. },
  107. deletePresent: function() {
  108. Dialog.confirm({
  109. message: '确认删除礼物吗?'
  110. }).then(() => {
  111. // on confirm
  112. // TODO: 考虑 updateBatch, 就是需要 将isDel设为1, 配合首页查找进行过滤
  113. Toast.loading({
  114. mask: true,
  115. message: '加载中...',
  116. duration: 500
  117. });
  118. let that = this;
  119. BasicFunction.get_data("smartGoods/list?goodid=" + this.myPresent.id, function (response) {
  120. // console.log("------ Data Rcvd in detail --------");
  121. // console.log(response);
  122. try {
  123. let list = response.model.list;
  124. if (response.ret === "10000") {
  125. list[0].isDel = 1;
  126. // console.log(list);
  127. BasicFunction.get_data("smartGoods/updateBatch", function (response) {
  128. // console.log(response);
  129. if (response.ret === '10000') {
  130. Toast.success('删除成功');
  131. that.$router.push('index');
  132. } else {
  133. Toast.fail('删除失败,请检查网络');
  134. }
  135. }, list)
  136. } else Toast.fail('获取资源失败');
  137. } catch (e) {
  138. console.warn(e);
  139. Toast.fail('获取资源失败');
  140. }
  141. }, {});
  142. }).catch(() => {
  143. // on cancel
  144. });
  145. },
  146. toWriteComment: function () {
  147. this.$router.push('assess');
  148. }
  149. },
  150. created: function () {
  151. if (!localStorage.getItem('frontend-userid')) {
  152. this.$router.push('login');
  153. return;
  154. }
  155. let present = this.$route.query.present;
  156. // console.log(this.$route.query.present);
  157. let userid = localStorage.getItem('frontend-userid');
  158. let that = this;
  159. present.comment = '';
  160. BasicFunction.get_data('smartIdentity/list?userId=' + userid, function (res) {
  161. // console.log(res);
  162. try {
  163. let identity = res.model.list[0];
  164. if (res.ret === '10000') {
  165. present.placeId = identity.dormDistrict;
  166. present.wechat = identity.userWxAccount;
  167. that.myPresent = present;
  168. // console.log(that.myPresent);
  169. if (present.status === 3) BasicFunction.get_data('smartOrderFeedback/list?goodId=' + present.id, function (res) {
  170. // console.log(res);
  171. try {
  172. let comment = res.model.list[0];
  173. if (res.ret === '10000') {
  174. if (comment.length === 0) that.myPresent.comment = '暂未收到';
  175. else that.myPresent.comment = comment.content;
  176. } else Toast.fail('获取信息失败');
  177. } catch (e) {
  178. console.warn(e);
  179. Toast.fail('获取信息失败');
  180. }
  181. }, {});
  182. if (present.status === 4) BasicFunction.get_data('smartGoodReview/list?goodId=' + present.id, function (res) {
  183. // console.log(res);
  184. if (res.ret === '10000') {
  185. if (res.model.list.length !== 0) that.reason = res.model.list[0].displayNote;
  186. } else Toast.fail('获取信息失败');
  187. }, {});
  188. } else Toast.fail('获取信息失败');
  189. } catch (e) {
  190. console.warn(e);
  191. Toast.fail('获取信息失败');
  192. }
  193. }, {});
  194. }
  195. }
  196. </script>
  197. <style scoped>
  198. .letter {
  199. background-color: white;
  200. margin: 20px 20px;
  201. border: solid 1px #e4e4e4;
  202. padding: 0 15px;
  203. text-align: left;
  204. }
  205. </style>