index.vue 11 KB

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