index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div>
  3. <div style="position: relative;">
  4. <img :src="indexTop" style="max-width: 100%; position: relative;"/>
  5. </div>
  6. <van-row type="flex" justify="space-between" align="center" style="margin: 0 10px 0 15px">
  7. <van-col>
  8. <p><strong>我的礼物</strong></p>
  9. </van-col>
  10. <van-col>
  11. <van-button round type="primary" size="small" @click="toShare">邀请好友赢大奖</van-button>
  12. </van-col>
  13. </van-row>
  14. <ul style="background-color: #fff6e3">
  15. <li
  16. is="index-present"
  17. v-for="(present, index) in presents"
  18. :key="present.id"
  19. :present-name="present.presentName"
  20. :present-desc="present.desc"
  21. :publish-time="present.time"
  22. :status="present.status"
  23. @to-detail="toDetail(index)"
  24. ></li>
  25. </ul>
  26. <div style="margin: 50px 10px;">
  27. <p style="text-align: left; margin-left: 5px"><strong>简单四步,轻松互赠圣诞礼物</strong></p>
  28. <img src="../assets/declare_icons/declare.jpg" style="margin-bottom: 40px"/>
  29. </div>
  30. <add-present-button :can_add="button_active"/>
  31. </div>
  32. </template>
  33. <script>
  34. import IndexPresent from "../components/IndexPresent";
  35. import {Button, Row, Col} from "vant";
  36. import AddPresentButton from "../components/addPresentButton";
  37. import {BasicFunction} from '../connector/basic-service';
  38. export default {
  39. name: "index",
  40. components: {
  41. AddPresentButton,
  42. IndexPresent,
  43. [Button.name]: Button,
  44. [Row.name]: Row, [Col.name]: Col
  45. },
  46. data() {
  47. return {
  48. active: 0,
  49. indexTop: require('../assets/banner.png'),
  50. button_active: true,
  51. }
  52. },
  53. computed: {
  54. presents: function() {
  55. // return get_present_data()
  56. var userId = localStorage.getItem("frontend-userid");
  57. // 判断userId 是不是空的
  58. BasicFunction.get_data("smartGoods/list?ownerId" + userId, function (response) {
  59. console.log("------ Data Rcvd in Index --------");
  60. console.log(response);
  61. if (response.ret === "10000") {
  62. // response 就是
  63. console.warn(response);
  64. var list = response.model.list;
  65. if (list == undefined || list.length == 0) // ....
  66. console.warn(list);
  67. } else {
  68. // 注册失败的处理
  69. console.warn("注册失败");
  70. }
  71. }, {});
  72. return [
  73. {
  74. id: 0,
  75. presentName: '礼物1',
  76. desc: '描述1blabla',
  77. time: '2018-01-02',
  78. status: 1
  79. },
  80. {
  81. id: 1,
  82. presentName: '礼物2',
  83. desc: '描述2blabla啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊(max45)',
  84. time: '2018-11-02',
  85. status: 2
  86. }
  87. ]
  88. }
  89. },
  90. methods: {
  91. toShare() {
  92. this.$router.push('share')
  93. },
  94. toDetail(id) {
  95. this.$router.push({ path: 'giftDetail', query: { presentId: id } })
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. </style>