index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <gracePage :customHeader="false">
  3. <view class="container" slot="gBody">
  4. <swiper class="banner-swiper" autoplay :interval="5000" :duration="1000" @change="change" :circular="swiper.circular">
  5. <swiper-item class="banner-swiper-item" v-for="(v, k) in fetch.info.pic_bg" :key="k">
  6. <image :src="v" mode="widthFix"></image>
  7. </swiper-item>
  8. </swiper>
  9. <view class="content">
  10. <!-- section-1 begin -->
  11. <view class="section-1">
  12. <navigator class="item">
  13. <image :src="fetch.info.pic_cover" mode="widthFix"></image>
  14. <view class="wenyue-font">{{fetch.info.name}}</view>
  15. <view class="text-color-assist">{{fetch.info.desc}}</view>
  16. </navigator>
  17. <view class="item" v-if="fetch.info.uid > 0">
  18. <image :src="fetch.info.user.avatar" mode="widthFix" class="avatar"></image>
  19. <view class="wenyue-font">{{fetch.info.user.username}}</view>
  20. <view class="text-color-assist">{{fetch.info.user.author}}</view>
  21. </view>
  22. </view>
  23. <!-- section-2 end -->
  24. <!-- section-2 begin -->
  25. <view class="section-2">
  26. <view class="item" v-for="(v, k) in fetch.button" :key="k">
  27. <view class="title">
  28. <image :src="v.icon" v-if="v.icon" style="width:33px;height:33px;"></image>
  29. <view>{{v.name}}</view>
  30. </view>
  31. <view class="tips" v-if="v.info">{{v.info}}</view>
  32. </view>
  33. </view>
  34. <!-- section-2 end -->
  35. <view class="section-3">
  36. <view class="my-integral">
  37. <view class="tips">
  38. <rich-text :nodes="fetch.info.content"></rich-text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view v-if="buyState">
  44. <buy :id="id" :bgcolor="fetch.button.bgcolor" :color="fetch.button.color" :code="fetch.code" :name="fetch.info.name" @hideBuy="hideBuy" @share="share" @view="view"></buy>
  45. </view>
  46. <view v-if="rankingState">
  47. <ranking :id="id" :bgcolor="fetch.button.bgcolor" :color="fetch.button.color" @hideRanking="hideRanking"></ranking>
  48. </view>
  49. <view v-if="infoState">
  50. <info :id="id" :bgcolor="fetch.button.bgcolor" :color="fetch.button.color" @hideInfo="hideInfo"></info>
  51. </view>
  52. <dever-share ref="share" :id="id" :code="fetch.code" :data="fetch.share" v-if="fetch.share && fetch.code"></dever-share>
  53. <view class="mask buy-layer" v-if="inviteState && fetch.share_user && fetch.share_user.code">
  54. <view class="buytip-layer layer " catchtap="handleStop">
  55. <view class="buy-tit buy-user"><image :src="fetch.share_user.avatar" mode="widthFix"></image></view>
  56. <view class="buy-tit" style="margin-top: 10rpx;">{{fetch.share_user.username}}赠送{{fetch.info.ticket_name}}</view>
  57. <view v-if="fetch.share_user.ticket && fetch.share_user.ticket.desc">
  58. <text class="p">“{{fetch.share_user.ticket.desc}}”</text>
  59. <text class="p">—“他”是这么说的</text>
  60. </view>
  61. <view v-else>
  62. <text class="p">“{{fetch.share.content}}”</text>
  63. <text class="p">—{{fetch.share.title}}</text>
  64. </view>
  65. <view v-if="fetch.share_ticket">
  66. <text class="p">“{{fetch.share_ticket}}”</text>
  67. <text class="p">—你已拥有{{fetch.info.ticket_name}},你这么回复“他”吧</text>
  68. </view>
  69. <view class="btn-wrapper" v-if="!fetch.share_ticket">
  70. <view class="button cancel" @click="hideInvite">不要
  71. </view>
  72. <view class="button primary" :style="fetch.button.bgcolor" @click="saveTicket(fetch.share_user.code)">收下
  73. <button formType="submit"></button>
  74. </view>
  75. </view>
  76. <view class="btn-wrapper" v-if="fetch.share_ticket">
  77. <view class="button primary" style="margin: 0 auto;" @click="hideInvite" :style="fetch.button.bgcolor">关闭</view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </gracePage>
  83. </template>
  84. <script>
  85. import buy from "@/pages/dream/buy.vue";
  86. import ranking from "@/pages/dream/ranking.vue";
  87. import info from "@/pages/dream/info.vue";
  88. import deverShare from '@/lib/dever/components/share.vue';
  89. export default {
  90. data() {
  91. return {
  92. swipers: [
  93. "https://go.cdn.heytea.com/storage/ad/2020/05/21/bfd57914d80d4671b19f5d0ccc176cd5.jpg",
  94. "https://go.cdn.heytea.com/storage/ad/2020/05/24/49f9b50738dd47878cf1ab54c2eee2e0.jpg",
  95. "https://go.cdn.heytea.com/storage/ad/2020/05/01/e1c6915022c849fd9492377021aef454.jpg",
  96. "https://go.cdn.heytea.com/storage/ad/2020/04/27/db60b797c1cd4afabe9666e7df958ffd.jpg",
  97. "https://go.cdn.heytea.com/storage/ad/2020/05/21/4ba53dda599345bdaf28a08420dd1b6f.jpg"
  98. ],
  99. id : 0,
  100. swiper : {
  101. index : 0,
  102. circular : true,
  103. },
  104. fetch: {
  105. is_read : false,
  106. is_ticket : false,
  107. info : {},
  108. button : {},
  109. code : '',
  110. share : {},
  111. },
  112. buyState : false,
  113. rankingState : false,
  114. infoState : false,
  115. inviteState : true,
  116. }
  117. },
  118. onLoad(option) {
  119. this.id = option.id;
  120. this.code = option.code;
  121. },
  122. onShow() {
  123. if (this.id || this.code) {
  124. this.getData();
  125. }
  126. },
  127. // 重新加载
  128. onPullDownRefresh: function() {
  129. this.getData();
  130. },
  131. methods: {
  132. change : function(e) {
  133. this.swiper.index = e.detail.current;
  134. },
  135. getData : function() {
  136. var url = this.Dever.host + '/pages/dream/index';
  137. this.Dever.get(this, 'app/collection/?l=api.getInfo', {id:this.id,code:this.code,url:url}, function(t) {
  138. uni.setNavigationBarTitle({
  139. title:t.info.name
  140. });
  141. });
  142. },
  143. goView : function() {
  144. //是否登录
  145. var token = this.Dever.getToken();
  146. if (!token) {
  147. var self = this;
  148. this.Dever.alert('您还未登录,请先登录', 'none', function() {
  149. if (self.id) {
  150. self.Dever.login = 'user/login?id=' + self.id;
  151. } else if (self.code) {
  152. self.Dever.login = 'user/login?code=' + self.code;
  153. }
  154. self.Dever.checkLogin();
  155. });
  156. return;
  157. }
  158. //是否已经有权限阅读
  159. if (!this.fetch.is_read) {
  160. this.showBuy();
  161. } else {
  162. this.view();
  163. }
  164. },
  165. view : function() {
  166. this.Dever.location('dream/view?code='+this.fetch.code + '&name=' + this.fetch.info.name);
  167. },
  168. showInvite : function() {
  169. this.inviteState = true;
  170. },
  171. hideInvite : function() {
  172. this.inviteState = false;
  173. },
  174. saveTicket : function(code) {
  175. var self = this;
  176. this.Dever.post('app/user/?l=api.saveTicket', {code:code}, function(t) {
  177. self.Dever.alert('已收下');
  178. self.hideInvite();
  179. });
  180. },
  181. showBuy : function() {
  182. if (this.fetch.is_ticket) {
  183. this.buyState = true;
  184. }
  185. },
  186. hideBuy : function() {
  187. this.buyState = false;
  188. },
  189. hideRanking : function() {
  190. this.rankingState = false;
  191. },
  192. goRanking : function() {
  193. this.rankingState = true;
  194. },
  195. goInfo : function() {
  196. this.infoState = true;
  197. },
  198. hideInfo : function() {
  199. this.infoState = false;
  200. },
  201. share : function() {
  202. this.$refs.share.open();
  203. }
  204. },
  205. components:{
  206. buy,ranking,info,deverShare
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. page {
  212. max-height: 100%;
  213. }
  214. .banner-swiper {
  215. width: 100%;
  216. height: 600rpx;
  217. .banner-swiper-item {
  218. image {
  219. width: 100%;
  220. }
  221. }
  222. }
  223. .content {
  224. width: 100%;
  225. padding: 0 30rpx;
  226. position: relative;
  227. }
  228. .section-1 {
  229. position: relative;
  230. background-color: $bg-color-white;
  231. margin-top: -60rpx;
  232. border-radius: $border-radius-lg;
  233. padding: 60rpx 0;
  234. display: flex;
  235. margin-bottom: 30rpx;
  236. box-shadow: $box-shadow;
  237. .item {
  238. flex: 1;
  239. flex-shrink: 0;
  240. display: flex;
  241. flex-direction: column;
  242. align-items: center;
  243. position: relative;
  244. &:nth-child(1):after {
  245. content: '';
  246. position: absolute;
  247. right: 0;
  248. top: 0;
  249. bottom: 0;
  250. width: 2rpx;
  251. background-color: $border-color;
  252. }
  253. image {
  254. width: 100rpx;
  255. margin-bottom: 20rpx;
  256. }
  257. .wenyue-font {
  258. font-size: 48rpx;
  259. margin-bottom: 10rpx;
  260. }
  261. }
  262. }
  263. .section-2 {
  264. display: flex;
  265. justify-content: space-between;
  266. margin-bottom: 30rpx;
  267. .item {
  268. width: 335rpx;
  269. background-color: #EAEBEC;
  270. padding: $spacing-row-lg 0;
  271. display: flex;
  272. flex-direction: column;
  273. align-items: center;
  274. justify-content: center;
  275. border-radius: $border-radius-lg;
  276. .title {
  277. width: 100%;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. font-size: $font-size-lg;
  282. image {
  283. width: 60rpx;
  284. height: 60rpx;
  285. margin-right: 10rpx;
  286. }
  287. }
  288. .tips {
  289. color: $text-color-assist;
  290. font-size: $font-size-base;
  291. }
  292. }
  293. }
  294. .section-3 {
  295. margin-bottom: 30rpx;
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: center;
  299. font-size: $font-size-base;
  300. color: $text-color-assist;
  301. padding: 0 10rpx;
  302. .my-integral {
  303. flex: 1;
  304. display: flex;
  305. flex-direction: column;
  306. .integrals {
  307. display: flex;
  308. align-items: center;
  309. font-size: $font-size-lg;
  310. color: $text-color-base;
  311. margin-bottom: 10rpx;
  312. .neutra-font {
  313. margin-left: 10rpx;
  314. font-size: 42rpx;
  315. }
  316. }
  317. }
  318. .my-code {
  319. display: flex;
  320. flex-direction: column;
  321. align-items: center;
  322. padding: 0 30rpx;
  323. position: relative;
  324. image {
  325. width: 60rpx;
  326. height: 60rpx;
  327. margin-bottom: $spacing-col-sm;
  328. }
  329. &:before {
  330. content: " ";
  331. position: absolute;
  332. left: 0;
  333. top: 0;
  334. bottom: 0;
  335. border-left: 1rpx solid rgba($color: $border-color, $alpha: 0.6);
  336. }
  337. }
  338. }
  339. </style>