index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view class="outer">
  3. <wike-skeleton :count="4" v-if="showskeleton"></wike-skeleton>
  4. <view style="height: 66px;"></view>
  5. <z-paging ref="paging" refresher-complete-delay="200" v-model="drawList" @query="queryList">
  6. <view class="subsection">
  7. <tn-subsection :current="current" :list="subsectionlist" mode="button" :borderRadius="50"
  8. animationType="cubic-bezier" bold :height="90" @change="getsubsection"></tn-subsection>
  9. </view>
  10. <view style="padding: 150rpx 15rpx 30rpx 15rpx;">
  11. <view v-if="homeTemplate&&homeTemplate.banner&&homeTemplate.banner.length>0" class="wike_ad">
  12. <wike-ad></wike-ad>
  13. </view>
  14. <tn-waterfall v-if="drawList.length>0" ref="waterfall" v-model="drawList"
  15. @finish="handleWaterFallFinish">
  16. <template v-slot:left="{ leftList }">
  17. <view v-for="(item, index) in leftList" :key="item.id" class="product__item" @click="tnproduct(item.id)"
  18. >
  19. <!-- 这里使用.stop修饰符,阻止 -->
  20. <view class="item__image" >
  21. <tn-lazy-load :threshold="6000" height="100%"
  22. :image="item.imgs_file[0]?item.imgs_file[0]:item.previewUrl" :index="item.id"
  23. imgMode="widthFix"> </tn-lazy-load>
  24. <!-- <button class="item__btn" size="mini" @click="drawStyle">绘制同款</button> -->
  25. <view class="item__btn" @click.stop="drawStyle(item)">绘制同款</view>
  26. </view>
  27. </view>
  28. </template>
  29. <template v-slot:right="{ rightList }">
  30. <view v-for="(item, index) in rightList" :key="item.id" class="product__item" @click="tnproduct(item.id)"
  31. >
  32. <view class="item__image" >
  33. <tn-lazy-load :threshold="6000" height="100%"
  34. :image="item.imgs_file[0]?item.imgs_file[0]:item.previewUrl" :index="item.id"
  35. imgMode="widthFix">
  36. </tn-lazy-load>
  37. <view class="item__btn" @click.stop="drawStyle(item)">绘制同款</view>
  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 :currTabIndex='0' v-if="appInfo.page_template == 3" :is_aipainting="appInfo.is_aipainting"
  50. :onTabbar="true" :isShowAnimate="true" :appInfos="appInfo.page_template"></wike-tabbar2>
  51. <wike-tabbar :currTabIndex='0' v-else :onTabbar="true" :is_aipainting="appInfo.is_aipainting"
  52. :isShowAnimate="true" :appInfos="appInfo.page_template"></wike-tabbar>
  53. <u-modal @cancel="handleCancel" @confirm="handleConfirm" cancelText='退出登录' showCancelButton :show="showFixInfo"
  54. confirmColor="#26b3a0" confirmText="完善信息" title="请完善个人手机号信息后使用本应用"
  55. content='您已充值,但未绑定手机号,请完善信息以方便为您提供进一步的服务'></u-modal>
  56. <!-- 初始引导界面 -->
  57. <div class="leadBg" v-if="showInitLead">
  58. <div class="leadBox1" v-if="showLead1" :style="{'background-image': `url(${leadBaseUrl}index_lead1.png)`}">
  59. <div class="nextBtn" @click="nextLead">
  60. </div>
  61. </div>
  62. <div class="leadBox2" v-if="showLead2" :style="{'background-image': `url(${leadBaseUrl}index_lead2.png)`}">
  63. <div class="nextBtn" @click="finishLead">
  64. </div>
  65. </div>
  66. </div>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. mapMutations,
  72. mapActions,
  73. mapState,
  74. mapGetters
  75. } from 'vuex';
  76. import {
  77. apiurl
  78. } from '@/common/request/request';
  79. import $platform from '@/common/platform';
  80. import BaseUrl from '@/common/config.js';
  81. let rewardedVideoAd = null;
  82. export default {
  83. mixins: [],
  84. components: {},
  85. data() {
  86. return {
  87. leadBaseUrl: BaseUrl.leadBaseUrl,
  88. swiperList:[],
  89. showInitLead: false,
  90. showLead2: false,
  91. showLead1: true,
  92. list: [],
  93. drawList: [],
  94. subsectionlist: ['艺术照', 'MJ绘图', 'SD绘图'],
  95. engine: 'rh',
  96. current: 0,
  97. showskeleton: true,
  98. showFixInfo: false,
  99. };
  100. },
  101. computed: {
  102. ...mapGetters(['appInfo', 'userInfo', 'homeTemplate'])
  103. },
  104. onLoad(o) {
  105. this.showInitLead = !uni.getStorageSync('showInitLead')
  106. if (o.uniacid) {
  107. uni.setStorageSync('uniacid', o.uniacid)
  108. console.log('onload获取的应用ID----paiting', uni.getStorageSync('uniacid'));
  109. }
  110. },
  111. onShow() {
  112. this.$http('user.info').then(res => {
  113. if (res.code == 0) {
  114. this.showFixInfo = res.data.is_new;
  115. }
  116. })
  117. // 网络变化检测
  118. uni.onNetworkStatusChange(res => {
  119. this.isConnected = res.isConnected;
  120. });
  121. },
  122. onReady() {
  123. // #ifdef MP-WEIXIN
  124. if (wx.createRewardedVideoAd && this.appInfo.video_status == 1) {
  125. rewardedVideoAd = wx.createRewardedVideoAd({
  126. adUnitId: this.appInfo.video_id
  127. });
  128. rewardedVideoAd.onLoad(() => {
  129. console.log('onLoad event emit');
  130. });
  131. rewardedVideoAd.onError(err => {
  132. console.log('onError event emit', err);
  133. });
  134. rewardedVideoAd.onClose(res => {
  135. if (res && res.isEnded) {
  136. // 正常播放结束,可以下发游戏奖励
  137. this.memberAddCoin();
  138. this.showcoin = false;
  139. } else {
  140. // 播放中途退出,不下发游戏奖励
  141. uni.showToast({
  142. title: '看完广告后才可获得积分哦',
  143. icon: 'none'
  144. });
  145. }
  146. });
  147. }
  148. // #endif
  149. this.loading = false;
  150. },
  151. methods: {
  152. ...mapActions(['getUserInfo', 'showAuthModal', 'getUserData', 'logout']),
  153. nextLead() {
  154. this.showLead1 = false
  155. this.showLead2 = true
  156. },
  157. // gallerydetail(item){
  158. // let that = this
  159. // this.$http('gallery.detail',{
  160. // id:item.id,
  161. // type:item.engine
  162. // }).then(res=>{
  163. // if(res.code == 0){
  164. // if(this.engin == 'sd'){
  165. // for(var i =0;i<res.data.imgs_file.length;i++){
  166. // var url={
  167. // id: res.data.id,
  168. // type: 'image',
  169. // url: res.data.imgs_file[i],
  170. // }
  171. // }
  172. // }
  173. // }
  174. // })
  175. // },
  176. drawStyle(item){
  177. console.log(item)
  178. if(item.engine == 'rh'){
  179. uni.navigateTo({
  180. url:'/pages/painting/draw?rh_modalId=-1&rh_modalurl='+item.previewUrl
  181. })
  182. console.log('/pages/painting/draw?rh_modalId=-1&rh='+item.previewUrl,66666666666666)
  183. }else if(item.engine == 'mj'){
  184. uni.navigateTo({
  185. url:'/pages/painting/draw?prompt='+item.prompt+'&engine'+item.engine+'&model_name'+item.mode+'&refImg='+'undefined'
  186. })
  187. }
  188. console.log(3333333333,item)
  189. },
  190. finishLead() {
  191. this.showInitLead = false
  192. this.showLead2 = false
  193. uni.setStorageSync('showInitLead', true)
  194. },
  195. handleCancel() {
  196. this.showFixInfo = false
  197. this.logout()
  198. // uni.clearStorage()
  199. uni.reLaunch({
  200. url: '/pages/user/signin'
  201. })
  202. },
  203. handleConfirm() {
  204. uni.navigateTo({
  205. url: '/pages/user/userinfo?isNewUser=true'
  206. })
  207. },
  208. queryList(pageNo, pageSize) {
  209. //这里的pageNo和pageSize会自动计算好,直接传给服务器即可
  210. const params = {
  211. page: pageNo,
  212. limit: pageSize,
  213. engine: this.engine
  214. };
  215. this.$http('gallery.all', params).then(res => {
  216. if (res.code == 0) {
  217. uni.setNavigationBarTitle({
  218. title: this.appInfo.site_name
  219. });
  220. this.showskeleton = false
  221. if (pageNo == 1) {
  222. this.drawList = []
  223. }
  224. this.$refs.paging.complete(res.data.data);
  225. this.isLoading = false;
  226. }
  227. });
  228. },
  229. getsubsection(e) {
  230. console.log(e.index);
  231. this.current = e.index
  232. this.engine = e.index == 0 ? 'rh' : e.index == 1 ? 'mj' : 'sd'
  233. this.drawList = []
  234. this.$refs.paging.reload(true);
  235. },
  236. getcreate() {
  237. uni.navigateTo({
  238. url: '/pages/painting/draw'
  239. })
  240. },
  241. /* 瀑布流*/
  242. // 获取随机数据
  243. getRandomData() {
  244. // console.log(13);
  245. // this.loadStatus = 'loading'
  246. for (let i = 0; i < 10; i++) {
  247. let index = this.$t.number.randomInt(0, this.data.length - 1)
  248. let item = JSON.parse(JSON.stringify(this.data[index]))
  249. item.id = this.$t.uuid()
  250. this.list.push(item)
  251. // console.log(this.list);
  252. }
  253. },
  254. // 瀑布流加载完毕事件
  255. handleWaterFallFinish() {
  256. // this.loadStatus = 'loadmore'
  257. },
  258. tnproduct(id) {
  259. uni.navigateTo({
  260. url: '/pages/painting/details?urls=' + id + '&from=' + this.engine
  261. })
  262. }
  263. }
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. @import './index.scss';
  268. </style>