index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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="toShare">邀请好友赢大奖</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 Guide from "../components/guide";
  63. export default {
  64. name: "index",
  65. components: {
  66. Guide,
  67. AddPresentButton,
  68. IndexPresent,
  69. [Button.name]: Button,
  70. [Row.name]: Row, [Col.name]: Col,
  71. [Swipe.name]: Swipe, [SwipeItem.name]: SwipeItem,
  72. [NoticeBar.name]: NoticeBar
  73. },
  74. data() {
  75. return {
  76. images: [
  77. "http://pjczv6ygf.bkt.clouddn.com/banner/banner1.jpg",
  78. "http://pjczv6ygf.bkt.clouddn.com/banner/banner2.jpg",
  79. "http://pjczv6ygf.bkt.clouddn.com/banner/banner3.jpg"
  80. ],
  81. active: 0,
  82. button_active: false,
  83. presents: {},
  84. hasPresent: true,
  85. dec_icons: [
  86. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/1.png",
  87. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/2.png",
  88. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/3.png",
  89. "http://pjczv6ygf.bkt.clouddn.com/dec-icon/4.png",
  90. ],
  91. dec_words: [
  92. '填写资料',
  93. '上传礼物',
  94. '获得匹配',
  95. '线下交换'
  96. ],
  97. userStatus: 100
  98. }
  99. },
  100. methods: {
  101. toShare() {
  102. Toast.loading({
  103. mask: true,
  104. message: '加载中...',
  105. duration: 1000
  106. });
  107. this.$router.push('share')
  108. },
  109. toDetail(i) {
  110. if (this.userStatus === 500) {
  111. Dialog.confirm({
  112. message: '您的校卡审核未通过!请前往【我的】页面重新上传校卡,否则将不会为您审核礼物哦',
  113. confirmButtonText: '查看校卡信息',
  114. cancelButtonText: '查看礼物'
  115. }).then(() => {
  116. Toast.loading({
  117. mask: true,
  118. message: '加载中...',
  119. duration: 500
  120. });
  121. this.$router.push('me');
  122. }).catch(() => {
  123. Toast.loading({
  124. mask: true,
  125. message: '加载中...',
  126. duration: 1000
  127. });
  128. let present = this.presents[i];
  129. this.$router.push({
  130. path: 'giftDetail', query: {present: present}
  131. });
  132. });
  133. } else {
  134. Toast.loading({
  135. mask: true,
  136. message: '加载中...',
  137. duration: 1000
  138. });
  139. let present = this.presents[i];
  140. this.$router.push({
  141. path: 'giftDetail', query: {present: present}
  142. });
  143. }
  144. },
  145. Desc(i) {
  146. switch (i) {
  147. case 0:
  148. Toast.loading({
  149. mask: true,
  150. message: '加载中...',
  151. duration: 500
  152. });
  153. this.$router.push('me');
  154. break;
  155. case 1:
  156. Toast.loading({
  157. mask: true,
  158. message: '加载中...',
  159. duration: 500
  160. });
  161. if (this.button_active) this.$router.push('verify');
  162. else Dialog.alert({
  163. message: '只能上传一个礼物哦'
  164. }).then(() => {
  165. });
  166. break;
  167. case 2:
  168. Dialog.alert({
  169. title: '获得匹配',
  170. message: '获得匹配后,请返回此页面,点击礼物查看匹配'
  171. }).then(() => {
  172. });
  173. break;
  174. case 3:
  175. Dialog.alert({
  176. title: '线下交换',
  177. message: '请联系匹配到的同学进行线下交换,我们将提供该同学的微信号'
  178. }).then(() => {
  179. });
  180. }
  181. }
  182. },
  183. created: function () {
  184. // return get_present_data()
  185. if (localStorage.getItem('frontend-userid') === null) {
  186. this.$router.push('login');
  187. return;
  188. }
  189. let userid = localStorage.getItem('frontend-userid');
  190. // console.log(userid);
  191. let presentList = [];
  192. let b_a = true;
  193. let h_p = false;
  194. let that = this;
  195. BasicFunction.get_data("smartIdentity/list?userId=" + userid, function (res) {
  196. // if(res.model === undefined || res.model.length === 0) {
  197. // Toast.fail('无法获取用户信息,请退出重试');
  198. // return;
  199. // }
  200. try {
  201. let identity = res.model.list[0];
  202. if (res.ret === '10000') {
  203. that.userStatus = identity.userReviewStatus;
  204. BasicFunction.get_data("smartGoods/list?isDel=0&ownerId=" + userid, function (response) {
  205. // console.log("------ Data Rcvd in Index --------");
  206. // console.log(response);
  207. if (response.ret === "10000") {
  208. let list = response.model.list;
  209. if (list.length !== 0) h_p = true;
  210. that.hasPresent = h_p;
  211. list.forEach(gift => {
  212. let temp = {};
  213. temp.id = gift.goodid;
  214. temp.imgUrl = 'http://gift.fogice.com' + gift.img;
  215. temp.name = gift.name;
  216. if (gift.description.length > 45) {
  217. temp.desc = gift.description.substring(0, 30);
  218. temp.desc += "..."
  219. }
  220. else temp.desc = gift.description;
  221. temp.desc_long = gift.description;
  222. temp.time = gift.createTime.substring(0, 9);
  223. temp.status = gift.sort;
  224. if (gift.sort !== 4) b_a = false; // 限制上传1个礼物
  225. temp.gender = gift.goodFirstKind;
  226. temp.tags = gift.goodSecondKind;
  227. presentList.push(temp);
  228. });
  229. that.button_active = b_a;
  230. } else Toast.fail('获取礼物列表失败');
  231. }, {});
  232. } else Toast.fail('获取信息失败');
  233. } catch (e) {
  234. console.warn(e);
  235. Toast.fail('无法获取用户信息,请退出重试' + e);
  236. }
  237. }, {});
  238. // console.log("presents:");
  239. // console.log(presentList);
  240. this.presents = presentList;
  241. },
  242. mounted: function () {
  243. document.getElementsByName("index_icon")[0].click(); // 保证导航栏正确
  244. }
  245. }
  246. </script>
  247. <style scoped>
  248. .dec {
  249. float: left;
  250. width: 25%;
  251. margin-bottom: 10px;
  252. }
  253. .dec img {
  254. width: 50%;
  255. background-color: white;
  256. border-radius: 50%;
  257. padding: 5px;
  258. margin-bottom: 0;
  259. }
  260. .dec p {
  261. font-size: 80%;
  262. margin-top: 2px;
  263. color: #9e9e9e;
  264. }
  265. </style>