index.vue 11 KB

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