index.vue 11 KB

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