index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div>
  3. <guide style="z-index: 3" v-if="hasPresent === false"/>
  4. <van-swipe :autoplay="3000" style="margin: 10px 10px;" :initial-swipe="1">
  5. <van-swipe-item v-for="(image, index) in images" :key="index">
  6. <img v-lazy="image" style="width: 100%"/>
  7. </van-swipe-item>
  8. </van-swipe>
  9. <van-notice-bar
  10. text="上传礼物需要被审核,请经常来看看审核是否通过,截止时间是24号21:00,25号0点开始将陆续放出配对结果"
  11. left-icon="//img.yzcdn.cn/vant/volume.png"
  12. />
  13. <van-row type="flex" justify="space-between" align="center" style="margin: 0 10px 0 15px">
  14. <van-col>
  15. <p><strong>我的礼物</strong></p>
  16. </van-col>
  17. <van-col>
  18. <van-button round type="primary" size="small" @click="toDraw">参加抽奖</van-button>
  19. </van-col>
  20. </van-row>
  21. <ul style="background-color: #fff6e3">
  22. <li
  23. is="index-present"
  24. v-for="(present, index) in presents"
  25. :key="present.id"
  26. :present-img="present.imgUrl"
  27. :present-name="present.name"
  28. :present-desc="present.desc"
  29. :publish-time="present.time"
  30. :status="present.status"
  31. @to-detail="toDetail(index)"
  32. ></li>
  33. </ul>
  34. <div style="margin: 20px 10px 0;">
  35. <p style="text-align: left; margin-left: 5px"><strong>简单四步,轻松互赠圣诞礼物</strong></p>
  36. <div
  37. class="dec"
  38. v-for="(pic, index) in dec_icons"
  39. :key="index"
  40. @click="Desc(index)"
  41. >
  42. <img :src="pic"/>
  43. <p>{{dec_words[index]}}</p>
  44. </div>
  45. </div>
  46. <div style="margin: 20px 10px 80px; font-size: 15px">
  47. <p style="margin-bottom: 0">Tips:</p>
  48. <p style="margin-top: 5px">我们十分重视您的礼物<br/> 如果使用中遇到疑惑 <br/> 欢迎您随时微信联系 177-8875-2557 </p>
  49. </div>
  50. <add-present-button :can_add="button_active"/>
  51. </div>
  52. </template>
  53. <script>
  54. import IndexPresent from "../components/IndexPresent";
  55. import {
  56. Button, Row, Col,
  57. Swipe, SwipeItem,
  58. NoticeBar, Toast, Dialog
  59. } from "vant";
  60. import AddPresentButton from "../components/addPresentButton";
  61. import {BasicFunction} from '../connector/basic-service';
  62. import * as methods from '../connector/get-data-methods';
  63. import Guide from "../components/guide";
  64. export default {
  65. name: "index",
  66. components: {
  67. Guide,
  68. AddPresentButton,
  69. IndexPresent,
  70. [Button.name]: Button,
  71. [Row.name]: Row, [Col.name]: Col,
  72. [Swipe.name]: Swipe, [SwipeItem.name]: SwipeItem,
  73. [NoticeBar.name]: NoticeBar
  74. },
  75. data() {
  76. return {
  77. images: [
  78. "http://pjczv6ygf.bkt.clouddn.com/banner/banner1.jpg",
  79. "http://pjczv6ygf.bkt.clouddn.com/banner/banner2.jpg",
  80. "http://pjczv6ygf.bkt.clouddn.com/banner/banner3.jpg"
  81. ],
  82. active: 0,
  83. button_active: false,
  84. presents: {},
  85. hasPresent: true,
  86. dec_icons: [
  87. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/1.png",
  88. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/2.png",
  89. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/3.png",
  90. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/4.png",
  91. ],
  92. dec_words: [
  93. '填写资料',
  94. '上传礼物',
  95. '获得匹配',
  96. '线下交换'
  97. ],
  98. userStatus: 100
  99. }
  100. },
  101. methods: {
  102. toDraw() {
  103. Toast.loading({
  104. mask: true,
  105. message: '加载中...',
  106. duration: 1000
  107. });
  108. this.$router.push('draw')
  109. },
  110. toDetail(i) {
  111. if (this.userStatus === 500) {
  112. Dialog.confirm({
  113. message: '您的校卡审核未通过!请前往【我的】页面重新上传校卡,否则将不会为您审核礼物哦',
  114. confirmButtonText: '查看校卡信息',
  115. cancelButtonText: '查看礼物'
  116. }).then(() => {
  117. Toast.loading({
  118. mask: true,
  119. message: '加载中...',
  120. duration: 500
  121. });
  122. this.$router.push('me');
  123. }).catch(() => {
  124. Toast.loading({
  125. mask: true,
  126. message: '加载中...',
  127. duration: 1000
  128. });
  129. let present = this.presents[i];
  130. this.$router.push({
  131. path: 'giftDetail', query: {presentId: present.goodid}
  132. });
  133. });
  134. } else {
  135. Toast.loading({
  136. mask: true,
  137. message: '加载中...',
  138. duration: 1000
  139. });
  140. let present = this.presents[i];
  141. this.$router.push({
  142. path: 'giftDetail', query: {presentId: present.id}
  143. });
  144. }
  145. },
  146. Desc(i) {
  147. switch (i) {
  148. case 0:
  149. Toast.loading({
  150. mask: true,
  151. message: '加载中...',
  152. duration: 500
  153. });
  154. this.$router.push('me');
  155. break;
  156. case 1:
  157. Toast.loading({
  158. mask: true,
  159. message: '加载中...',
  160. duration: 500
  161. });
  162. if (this.button_active) this.$router.push('verify');
  163. else Dialog.alert({
  164. message: '只能上传一个礼物哦'
  165. }).then(() => {
  166. });
  167. break;
  168. case 2:
  169. Dialog.alert({
  170. title: '获得匹配',
  171. message: '获得匹配后,请返回此页面,点击礼物查看匹配'
  172. }).then(() => {
  173. });
  174. break;
  175. case 3:
  176. Dialog.alert({
  177. title: '线下交换',
  178. message: '请联系匹配到的同学进行线下交换,我们将提供该同学的微信号'
  179. }).then(() => {
  180. });
  181. }
  182. }
  183. },
  184. created: function () {
  185. // return get_present_data()
  186. if (localStorage.getItem('frontend-userid') === null) {
  187. this.$router.push('login');
  188. return;
  189. }
  190. let userid = localStorage.getItem('frontend-userid');
  191. // console.log(userid);
  192. let presentList = [];
  193. let b_a = true;
  194. let h_p = false;
  195. let that = this;
  196. // let list = methods.get_present_list(userid);
  197. // console.log('presents: ');
  198. // console.log(list);
  199. BasicFunction.get_data("smartIdentity/list?userId=" + userid, function (res) {
  200. // if(res.model === undefined || res.model.length === 0) {
  201. // Toast.fail('无法获取用户信息,请退出重试');
  202. // return;
  203. // }
  204. try {
  205. if (res.ret === '10000' && res.model != undefined && res.model.list != undefined && res.model.list.length > 0) {
  206. let identity = res.model.list[0];
  207. that.userStatus = identity.userReviewStatus;
  208. BasicFunction.get_data("smartGoods/list?isDel=0&ownerId=" + userid, function (response) {
  209. // console.log("------ Data Rcvd in Index --------");
  210. // console.log(response);
  211. if (response.ret === "10000") {
  212. let list = response.model.list;
  213. if (list.length !== 0) h_p = true;
  214. that.hasPresent = h_p;
  215. list.forEach(gift => {
  216. let temp = {};
  217. temp.id = gift.goodid;
  218. temp.imgUrl = 'http://gift.fogice.com' + gift.img;
  219. temp.name = gift.name;
  220. if (gift.description.length > 45) {
  221. temp.desc = gift.description.substring(0, 30);
  222. temp.desc += "..."
  223. }
  224. else temp.desc = gift.description;
  225. temp.desc_long = gift.description;
  226. temp.time = gift.createTime.substring(0, 9);
  227. temp.status = gift.sort;
  228. if (gift.sort !== 4) b_a = false; // 限制上传1个礼物
  229. temp.gender = gift.goodFirstKind;
  230. temp.tags = gift.goodSecondKind;
  231. presentList.push(temp);
  232. });
  233. that.button_active = b_a;
  234. } else {
  235. Toast.fail('获取礼物列表失败');
  236. }
  237. }, {});
  238. } else {
  239. Toast.fail('获取信息失败');
  240. localStorage.removeItem('frontend-userid')
  241. }
  242. } catch (e) {
  243. console.warn(e);
  244. localStorage.removeItem('frontend-userid');
  245. Toast.fail('无法获取用户信息,请退出重试' + e);
  246. }
  247. }, {});
  248. // console.log("presents:");
  249. // console.log(presentList);
  250. this.presents = presentList;
  251. },
  252. mounted: function () {
  253. document.getElementsByName("index_icon")[0].click(); // 保证导航栏正确
  254. }
  255. }
  256. </script>
  257. <style scoped>
  258. .dec {
  259. float: left;
  260. width: 25%;
  261. margin-bottom: 10px;
  262. }
  263. .dec img {
  264. width: 50%;
  265. background-color: white;
  266. border-radius: 50%;
  267. padding: 5px;
  268. margin-bottom: 0;
  269. }
  270. .dec p {
  271. font-size: 80%;
  272. margin-top: 2px;
  273. color: #9e9e9e;
  274. }
  275. </style>