index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <view class="pages">
  3. <!-- <view class="" :style="{height: navHeight+'px' }"></view> -->
  4. <view class="banner">
  5. <!-- <image :src="staticUrl+'/img/index-banner.png'" ></image> -->
  6. <u-swiper
  7. :list="bannerList"
  8. height="600rpx"
  9. indicatorMode="dot"
  10. :indicatorStyle="{bottom:'100rpx'}"
  11. keyName="sliderImg"
  12. radius="0"
  13. indicator
  14. circular
  15. ></u-swiper>
  16. </view>
  17. <!-- 占位 banner -->
  18. <view class="holdbanner" style="height: 600rpx;pointer-events:none"></view>
  19. <!-- 页面滚动banner模糊 -->
  20. <view class="blurbanner" style="height: 600rpx;" :class="{ isblur: isblur }"></view>
  21. <view class="index-bg" :style="{backgroundImage:`url(${staticUrl}/img/index-bg.png?a=1)`}"></view>
  22. <view class="page-wrap">
  23. <view class="star-title u-flex u-row-between">
  24. <view class="left u-flex">
  25. <image class="icon" :src="staticUrl+'/img/title-star.png'" ></image>
  26. <text class="text">演出剧目</text>
  27. </view>
  28. </view>
  29. <swiper class="swiper" :autoplay="true" style="height: 400rpx;margin-bottom: 34rpx" >
  30. <swiper-item :item-id="item.id" v-for="(item,index) in theatreList" :key="index">
  31. <view class="programme-wrap">
  32. <view class="programme">
  33. <image class="img" :src="item.showImg" ></image>
  34. <!-- <image class="img" :src="item.showImg" ></image> -->
  35. <view class="text u-flex u-row-between">
  36. <view class="left">
  37. <view class="name">{{item.name}}</view>
  38. <!-- <view class="addr">演出地点:{{item.address}}</view> -->
  39. </view>
  40. <view class="btn" @click="bookticket(item)">立即预定</view>
  41. </view>
  42. <!-- <view class="share" @click="getPoster(item)">
  43. <image class="icon" :src="staticUrl+'/img/share-ico.png'" ></image>
  44. </view> -->
  45. </view>
  46. </view>
  47. </swiper-item>
  48. </swiper>
  49. </view>
  50. <view class="news-wrap">
  51. <view class="star-title u-flex u-row-between">
  52. <view class="left u-flex">
  53. <image class="icon" :src="staticUrl+'/img/title-star.png'" ></image>
  54. <text class="text">演出资讯</text>
  55. </view>
  56. <view class="right u-flex">
  57. <text class="text" @click="$u.route('pages/news')">更多</text>
  58. <u-icon name="arrow-right" color="#C79191" size="36rpx"></u-icon>
  59. </view>
  60. </view>
  61. <view class="news">
  62. <u-scroll-list :indicator="false">
  63. <view class="item" v-for="(item, index) in newsList" @click="newsClick(item)" :key="index">
  64. <image class="img" :src="item.showImg||staticUrl+'/img/newsdetails-banner.png'"></image>
  65. <view class="text">
  66. <view class="name u-line-1">{{item.title}}</view>
  67. <view class="con u-line-1">{{item.centent}}</view>
  68. <view class="time u-flex u-row-between">
  69. <view class="left">{{$u.timeFormat(item.onlineTime, 'yyyy-mm-dd')}}</view>
  70. <image class="icon" :src="staticUrl+'/img/arrow-right-ico.png'" ></image>
  71. </view>
  72. </view>
  73. </view>
  74. </u-scroll-list>
  75. </view>
  76. </view>
  77. <!-- content-wrap end -->
  78. <!-- <image class="activity" :src="staticUrl+'/img/activity.png'" ></image> -->
  79. <!-- 分享选择弹出内容 -->
  80. <view class="share-option" :class="{shareShow:shareShow}">
  81. <view class="overlay" v-if="shareShow" @click="shareShow=false"></view>
  82. <button class="share-option-item wx-share" data-name="shareBtn" open-type="share">
  83. 发送给朋友
  84. </button>
  85. <view class="share-option-item" @click="getPoster">生成海报</view>
  86. <view class="share-option-item" @click="shareShow=false">取消</view>
  87. </view>
  88. <u-popup :show="posterShow" @close="posterShow=false" ref="uni-popup">
  89. <view class="poster-wrap u-flex u-col-center">
  90. <view class="poster-inner">
  91. <view class="close-wrap" @click="posterShow=false">
  92. <u-icon name="close-circle" color="#fff" size="56rpx"></u-icon>
  93. </view>
  94. <view class="poster" id="poster" ref="poster" >
  95. <u--image :showLoading="true" :src="posterSrc" width="100%" height="65vh" mode="aspectFit"></u--image>
  96. </view>
  97. <!-- savePoster -->
  98. <view class="poster-btn" @click="saveImage">保存图片</view>
  99. </view>
  100. </view>
  101. </u-popup>
  102. <u-toast ref="uToast"></u-toast>
  103. <tabbar :tabbarIndexProps='0' />
  104. </view>
  105. </template>
  106. <script>
  107. import { systemInfo } from "@/mixin.js";
  108. import tabbar from "../../components/tabbar.vue";
  109. export default {
  110. components:{
  111. tabbar,
  112. // cartfixed
  113. },
  114. mixins:[systemInfo],
  115. data() {
  116. return {
  117. staticUrl:this.$commonConfig.staticUrl,
  118. bannerList: [],
  119. theatreList:[],//剧院信息列表
  120. bannerCurrent: 0,
  121. isblur:false,
  122. newsList:[],//资讯
  123. shareShow:false,
  124. posterShow:false,
  125. posterStyle:{},
  126. posterSrc:'',
  127. templateIdList:[],//微信小程序订阅消息
  128. }
  129. },
  130. computed: {
  131. },
  132. onShow() {
  133. },
  134. beforeRouteLeave() {
  135. },
  136. onLoad(query) {
  137. this.getSystemInfo();
  138. // console.log('statusBarHeight',this.statusBarHeight);
  139. // console.log('navigationBarHeight',this.navigationBarHeight);
  140. // console.log('windowHeight',this.windowHeight);
  141. // console.log('navHeight',this.navHeight);
  142. // console.log('vuex_member_info=======',this.vuex_member_info);
  143. this.getClientIndex();
  144. this.getTemplateIdList();
  145. },
  146. onReady() {
  147. },
  148. onUnload() {
  149. },
  150. methods: {
  151. getMemberInfo(){
  152. this.$u.api.memberInfo({id:this.vuex_member_info.id}).then(res=>{
  153. this.memberInfo = res.data;
  154. this.avatar = res.data.avatar;
  155. this.$u.vuex('vuex_member_info', res.data);
  156. // console.log('memberInfo',this.memberInfo);
  157. }).catch(err=>{
  158. // console.log('memberInfo',err.data);
  159. })
  160. },
  161. getHotGoods(){
  162. this.$u.api.topGoodList({pageNum:1,pageSize:20}).then(res=>{
  163. this.hotGoods = res.data.rows;
  164. console.log('res',res);
  165. }).catch(err=>{
  166. console.log('getHotGoods',err.data);
  167. })
  168. },
  169. getClientIndex(){
  170. this.$u.api.clientIndex().then(res=>{
  171. // console.log('res',res);
  172. this.bannerList = res.data.advList;
  173. this.theatreList = res.data.performList;
  174. this.newsList = res.data.informationList;
  175. }).catch(err=>{
  176. console.log('getClientIndex',err.data);
  177. })
  178. },
  179. goLogin(){
  180. uni.$u.route('/pages/login/login')
  181. },
  182. onPageScroll(e){
  183. if(e.scrollTop>100){
  184. this.isblur = true
  185. }else{
  186. this.isblur = false
  187. }
  188. },
  189. bookticket(item){
  190. // console.log('bookticket',item);
  191. uni.$u.route('pages/ticketlist',{id:item.id})
  192. },
  193. openShare(){
  194. this.shareShow = true;
  195. },
  196. // 海报相关开始
  197. getPoster(item){
  198. this.posterShow = true;
  199. this.shareShow = false;
  200. this.$u.api.performQrcode({performId:item.id}).then(res=>{
  201. this.posterSrc = res.data.imageUrl;
  202. // console.log('getPoster',res.data);
  203. }).catch(err=>{
  204. console.log('getPoster',err);
  205. })
  206. },
  207. saveImage() {
  208. let that = this;
  209. uni.showLoading({
  210. title: '保存中'
  211. });
  212. uni.downloadFile({
  213. url: this.posterSrc,
  214. success(res) {
  215. if (res.statusCode === 200) {
  216. uni.saveImageToPhotosAlbum({
  217. filePath: res.tempFilePath,
  218. success() {
  219. uni.showToast({
  220. title: '保存到相册成功',
  221. icon: 'success'
  222. });
  223. },
  224. fail(err) {
  225. console.log('保存图片失败',err);
  226. if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
  227. uni.getSetting({
  228. success(res) {
  229. if (!res.authSetting['scope.writePhotosAlbum']) {
  230. uni.showModal({
  231. title: '提示',
  232. content: '您还没有授权访问相册,请前往设置页面打开权限。',
  233. confirmText: '去设置',
  234. success(res) {
  235. if (res.confirm) {
  236. uni.openSetting();
  237. }
  238. }
  239. });
  240. } else {
  241. uni.showToast({
  242. title: '保存图片失败',
  243. icon: 'none'
  244. });
  245. }
  246. }
  247. });
  248. } else {
  249. uni.showToast({
  250. title: '保存图片失败',
  251. icon: 'none'
  252. });
  253. }
  254. },
  255. complete() {
  256. uni.hideLoading();
  257. that.posterShow = false;
  258. }
  259. });
  260. } else {
  261. uni.showToast({
  262. title: '下载图片失败',
  263. icon: 'none'
  264. });
  265. }
  266. },
  267. fail() {
  268. uni.showToast({
  269. title: '下载图片失败',
  270. icon: 'none'
  271. });
  272. }
  273. });
  274. },
  275. // 海报相关结束
  276. newsClick(item){
  277. uni.$u.route('/pages/newsdetails', {
  278. id: item.id,
  279. type:'news'
  280. });
  281. },
  282. getTemplateIdList(){
  283. this.$u.api.templateIdList().then(res=>{
  284. console.log('res',res.data);
  285. if(this.templateIdList.length>0){
  286. this.templateEven();
  287. }
  288. }).catch(err=>{
  289. console.log('getTemplateIdList',err);
  290. })
  291. },
  292. // 订阅消息
  293. templateEven(){
  294. let that = this
  295. wx.showModal({
  296. title: '温馨提示',
  297. content: '为更好的促进与您的交流,服务号需要实时向您发送消息',
  298. confirmText:"同意",
  299. cancelText:"拒绝",
  300. success: function (res) {
  301. if (res.confirm) {
  302. //调用订阅消息
  303. console.log('用户点击确定');
  304. //调用订阅
  305. that.setTemplate();
  306. } else if (res.cancel) {
  307. console.log('用户点击取消');
  308. ///显示第二个弹说明一下
  309. wx.showModal({
  310. title: '温馨提示',
  311. content: '拒绝后您将无法获取实时的消息',
  312. confirmText:"知道了",
  313. showCancel:false,
  314. success: function (res) {
  315. ///点击知道了的后续操作
  316. ///如跳转首页面
  317. }
  318. });
  319. }
  320. }
  321. });
  322. },
  323. // 设置小程序订阅消息
  324. setTemplate() {
  325. // console.log('templateIdList',this.templateIdList);
  326. wx.requestSubscribeMessage({
  327. tmplIds: this.templateIdList,
  328. success (res) {
  329. console.log("success:",res);
  330. },
  331. fail (res) {
  332. console.log("fail:",res);
  333. },
  334. complete (res) {
  335. console.log("complete:",res);
  336. }
  337. })
  338. },
  339. }
  340. }
  341. </script>
  342. <style>
  343. page{
  344. }
  345. </style>
  346. <style lang="scss" scoped>
  347. $pagegap:32rpx;
  348. .banner{
  349. position: fixed;
  350. left: 0;
  351. top: 0;
  352. width: 100%;
  353. }
  354. .blurbanner{
  355. pointer-events: none;
  356. position: fixed;
  357. left: 0;
  358. top: 0;
  359. width: 100%;
  360. transition: all 0.3s;
  361. &.isblur{
  362. backdrop-filter: blur(8px);
  363. }
  364. }
  365. .index-bg{
  366. position: fixed;
  367. display: block;
  368. left: 0;
  369. bottom: 0;
  370. width: 100%;
  371. min-height: calc( 100vh - 600rpx + 50rpx );
  372. background-repeat: no-repeat;
  373. background-position: top center;
  374. background-size: 100% auto;
  375. // z-index: -1;
  376. }
  377. .page-wrap{
  378. position: relative;
  379. }
  380. .star-title{
  381. margin-bottom: 32rpx;
  382. .left{
  383. .icon{
  384. width: 28rpx;
  385. height: 28rpx;
  386. margin-right: 8rpx;
  387. }
  388. .text{
  389. font-size: 32rpx;
  390. font-weight: bold;
  391. color: #FFFFFF;
  392. line-height: 48rpx;
  393. background: linear-gradient(128deg, #FFEFBC 0%, #FFD767 100%);
  394. -webkit-background-clip: text;
  395. -webkit-text-fill-color: transparent;
  396. }
  397. }
  398. .right{
  399. .text{
  400. font-size: 24rpx;
  401. font-weight: 400;
  402. color: #C79191;
  403. }
  404. }
  405. }
  406. .programme-wrap{
  407. // margin-bottom: 64rpx;
  408. .programme{
  409. // background-color: #FFFFFF;
  410. position: relative;
  411. border-radius: 30rpx;
  412. overflow: hidden;
  413. background: radial-gradient(circle at -26rpx 230rpx, transparent 10%, #fff 4%) left, radial-gradient(circle at calc( 100% + 26rpx ) 232rpx, transparent 10%, #fff 4%) right;
  414. background-size: 50% 100%;
  415. background-repeat: no-repeat;
  416. .img{
  417. width: 100%;
  418. height: 242rpx;
  419. display: block;
  420. }
  421. .text{
  422. position: relative;
  423. &:before{
  424. content: '';
  425. width: calc( 100% - 32rpx );
  426. height: 1px;
  427. position: absolute;
  428. left: 20rpx;
  429. top: -2rpx;
  430. border-top: 4rpx dashed #931E0C;
  431. }
  432. padding: 32rpx 30rpx;
  433. .name{
  434. font-size: 28rpx;
  435. font-weight: bold;
  436. color: #363636;
  437. line-height: 42rpx;
  438. // margin-bottom: 18rpx;
  439. }
  440. .addr{
  441. font-size: 22rpx;
  442. font-weight: 400;
  443. color: #7F7F7F;
  444. line-height: 34rpx;
  445. }
  446. .btn{
  447. height: 51rpx;
  448. line-height: 51rpx;
  449. padding: 0 24rpx;
  450. background: linear-gradient(90deg, #FF7979 0%, #ED0000 100%);
  451. border-radius: 25rpx;
  452. font-size: 20rpx;
  453. font-weight: 400;
  454. color: #FFFFFF;
  455. }
  456. }
  457. .share{
  458. position: absolute;
  459. right: 16rpx;
  460. top: 16rpx;
  461. padding: 10rpx;
  462. border-radius: 50%;
  463. background-color: rgba(0,0,0,0.4);
  464. .icon{
  465. display: block;
  466. width: 32rpx;
  467. height: 32rpx;
  468. }
  469. }
  470. }
  471. }
  472. .news-wrap{
  473. position: relative;
  474. margin-left: $pagegap;
  475. margin-bottom: 180rpx;
  476. .star-title{
  477. margin-right: $pagegap;
  478. }
  479. .item{
  480. width: 434rpx;
  481. flex-shrink: 0;
  482. margin-right: 20rpx;
  483. background: #FFFFFF;
  484. box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(59,0,0,0.5);
  485. border-radius: 12rpx;
  486. overflow: hidden;
  487. .img{
  488. display: block;
  489. width: 100%;
  490. height: 174rpx;
  491. }
  492. .text{
  493. padding: 30rpx 20rpx 22rpx;
  494. .name{
  495. font-size: 28rpx;
  496. font-weight: bold;
  497. color: #333333;
  498. margin-bottom: 12rpx;
  499. }
  500. .con{
  501. font-size: 24rpx;
  502. font-weight: 400;
  503. color: #6B6B6B;
  504. // line-height: 22rpx;
  505. margin-bottom: 20rpx;
  506. }
  507. .time{
  508. font-size: 20rpx;
  509. font-weight: 400;
  510. color: #C0C0C0;
  511. line-height: 22rpx;
  512. }
  513. .icon{
  514. display: block;
  515. width: 80rpx;
  516. height: 20rpx;
  517. }
  518. }
  519. }
  520. }
  521. .activity{
  522. display: block;
  523. width: 112rpx;
  524. height: 132rpx;
  525. position: fixed;
  526. right: 16rpx;
  527. bottom: 174rpx;
  528. }
  529. </style>