index.vue 10 KB

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