painting.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view>
  3. <!-- <view class="subsection">
  4. <tn-subsection :list="subsectionlist" mode="button" :borderRadius="50"
  5. animationType="cubic-bezier" bold :height="90" @change="getsubsection"></tn-subsection>
  6. </view> -->
  7. <wike-skeleton :count="4" v-if="showskeleton"></wike-skeleton>
  8. <view style="height: 66px;"></view>
  9. <z-paging ref="paging" refresher-complete-delay="200" v-model="drawList" @query="queryList">
  10. <!-- <view slot="top" class="z_tabs" :style="{ marginTop: 66 + 'px' ,background: 'none'}"></view> -->
  11. <view class="subsection">
  12. <tn-subsection :list="subsectionlist" mode="button" :borderRadius="50" animationType="cubic-bezier" bold
  13. :height="90" @change="getsubsection"></tn-subsection>
  14. </view>
  15. <view style="padding: 150rpx 15rpx 30rpx 15rpx;">
  16. <view v-if="homeTemplate&&homeTemplate.banner&&homeTemplate.banner.length>0" class="wike_ad">
  17. <wike-ad></wike-ad>
  18. </view>
  19. <tn-waterfall v-if="drawList.length>0" ref="waterfall" v-model="drawList"
  20. @finish="handleWaterFallFinish">
  21. <template v-slot:left="{ leftList }">
  22. <view v-for="(item, index) in leftList" :key="item.id" class="product__item"
  23. @click="tnproduct(item.id)">
  24. <view class="item__image">
  25. <tn-lazy-load :threshold="6000" height="100%"
  26. :image="item.imgs_file[0]?item.imgs_file[0]:item.origin_url" :index="item.id"
  27. imgMode="widthFix"></tn-lazy-load>
  28. </view>
  29. </view>
  30. </template>
  31. <template v-slot:right="{ rightList }">
  32. <view v-for="(item, index) in rightList" :key="item.id" class="product__item"
  33. @click="tnproduct(item.id)">
  34. <view class="item__image">
  35. <tn-lazy-load :threshold="6000" height="100%"
  36. :image="item.imgs_file[0]?item.imgs_file[0]:item.origin_url" :index="item.id"
  37. imgMode="widthFix"></tn-lazy-load>
  38. </view>
  39. </view>
  40. </template>
  41. </tn-waterfall>
  42. <!-- <wike-waterfall :dataList="data" :column="columns" @click="click" :radius="20" :margin="10"></wike-waterfall> -->
  43. </view>
  44. <view slot="bottom" class="z_tabs" :style="{ marginBottom: 72 + 'px' }"></view>
  45. </z-paging>
  46. <view @click="getcreate" class="suspension u-flex align-center justify-center">
  47. AI创作
  48. </view>
  49. <wike-tabbar2 v-if="appInfo.page_template == 3" :is_aipainting="appInfo.is_aipainting" :onTabbar="true"
  50. :isShowAnimate="true" :appInfos="appInfo.page_template"></wike-tabbar2>
  51. <wike-tabbar v-else :onTabbar="true" :is_aipainting="appInfo.is_aipainting" :isShowAnimate="true"
  52. :appInfos="appInfo.page_template"></wike-tabbar>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. mapMutations,
  58. mapActions,
  59. mapState,
  60. mapGetters
  61. } from 'vuex';
  62. import {
  63. apiurl
  64. } from '@/common/request/request';
  65. import $platform from '@/common/platform';
  66. let rewardedVideoAd = null;
  67. export default {
  68. mixins: [],
  69. components: {},
  70. data() {
  71. return {
  72. list: [],
  73. drawList: [],
  74. subsectionlist: ['StableDiffusion绘图', 'MidJourney绘图'],
  75. engine: 'sd',
  76. showskeleton: true
  77. };
  78. },
  79. computed: {
  80. ...mapGetters(['appInfo', 'userInfo', 'homeTemplate'])
  81. },
  82. onLoad() {
  83. // this.getRandomData()
  84. },
  85. onShow() {
  86. // 网络变化检测
  87. uni.onNetworkStatusChange(res => {
  88. this.isConnected = res.isConnected;
  89. });
  90. },
  91. onReady() {
  92. // #ifdef MP-WEIXIN
  93. if (wx.createRewardedVideoAd && this.appInfo.video_status == 1) {
  94. rewardedVideoAd = wx.createRewardedVideoAd({
  95. adUnitId: this.appInfo.video_id
  96. });
  97. rewardedVideoAd.onLoad(() => {
  98. console.log('onLoad event emit');
  99. });
  100. rewardedVideoAd.onError(err => {
  101. console.log('onError event emit', err);
  102. });
  103. rewardedVideoAd.onClose(res => {
  104. if (res && res.isEnded) {
  105. // 正常播放结束,可以下发游戏奖励
  106. this.memberAddCoin();
  107. this.showcoin = false;
  108. } else {
  109. // 播放中途退出,不下发游戏奖励
  110. uni.showToast({
  111. title: '看完广告后才可获得积分哦',
  112. icon: 'none'
  113. });
  114. }
  115. });
  116. }
  117. // #endif
  118. this.loading = false;
  119. },
  120. methods: {
  121. queryList(pageNo, pageSize) {
  122. //这里的pageNo和pageSize会自动计算好,直接传给服务器即可
  123. const params = {
  124. page: pageNo,
  125. limit: pageSize,
  126. engine: this.engine
  127. };
  128. this.$http('gallery.all', params).then(res => {
  129. if (res.code == 0) {
  130. uni.setNavigationBarTitle({
  131. title: this.appInfo.site_name
  132. });
  133. this.showskeleton = false
  134. if (pageNo == 1) {
  135. this.drawList = []
  136. }
  137. this.$refs.paging.complete(res.data.data);
  138. this.isLoading = false;
  139. }
  140. });
  141. },
  142. getsubsection(e) {
  143. // console.log(e);
  144. this.engine = e.index == 1 ? 'mj' : 'sd'
  145. this.drawList = []
  146. this.$refs.paging.reload(true);
  147. },
  148. getcreate() {
  149. uni.navigateTo({
  150. url: '/pages/painting/draw'
  151. })
  152. },
  153. /* 瀑布流*/
  154. // 获取随机数据
  155. getRandomData() {
  156. // console.log(13);
  157. // this.loadStatus = 'loading'
  158. for (let i = 0; i < 10; i++) {
  159. let index = this.$t.number.randomInt(0, this.data.length - 1)
  160. let item = JSON.parse(JSON.stringify(this.data[index]))
  161. item.id = this.$t.uuid()
  162. this.list.push(item)
  163. // console.log(this.list);
  164. }
  165. },
  166. // 瀑布流加载完毕事件
  167. handleWaterFallFinish() {
  168. // this.loadStatus = 'loadmore'
  169. },
  170. tnproduct(id) {
  171. uni.navigateTo({
  172. url: '/pages/painting/details?urls=' + id
  173. })
  174. }
  175. }
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. @import './painting.scss';
  180. </style>