index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view class="container">
  3. <wike-skeleton :count="4" v-if="homeTemplate.length === 0"></wike-skeleton>
  4. <view class="form" v-if="appInfo.page_template == 1 || !appInfo.page_template">
  5. <view class="top-notice" v-if="appInfo && appInfo.notice"><u-notice-bar
  6. :text="appInfo.notice"></u-notice-bar></view>
  7. <view class="logo"><u--image :src="appInfo.site_logo_path?appInfo.site_logo_path:'/static/images/head.jpg'"
  8. shape="circle" width="200rpx" height="200rpx"></u--image></view>
  9. <u-transition :show="true" mode="slide-left">
  10. <view class="title">{{ appInfo.site_name?appInfo.site_name:'A问答机器人' }}</view>
  11. </u-transition>
  12. <u-transition :show="true" mode="slide-right">
  13. <view class="desc">{{ appInfo.sub_title }}</view>
  14. </u-transition>
  15. <view class="btn-group">
  16. <view class="btn" @click="onToForm"><u-button shape="circle" iconColor="#ffffff" color="#26B3A0"
  17. icon="chat" text="立即体验"></u-button></view>
  18. <view v-if="appInfo.is_aipainting&&appInfo.is_aipainting == 1" class="btn" @click="ondraw"><u-button
  19. shape="circle" iconColor="#ffffff" color="#ffc107" icon="edit-pen-fill" text="Ai绘画"></u-button>
  20. </view>
  21. <view class="btn">
  22. <!-- #ifdef MP-WEIXIN -->
  23. <u-button shape="circle" open-type="share" color="#26B3A0" :plain="true" icon="share"
  24. text="分享好友"></u-button>
  25. <!-- #endif -->
  26. <!-- #ifdef H5 -->
  27. <u-button shape="circle" @click="h5share = true" color="#26B3A0" :plain="true" icon="share"
  28. text="分享好友"></u-button>
  29. <!-- #endif -->
  30. </view>
  31. </view>
  32. </view>
  33. <view v-if="appInfo.page_template == 2">
  34. <view class="directask">
  35. <!-- 📝 -->
  36. <view class="askaquestion u-flex align-center">
  37. <!-- <image src="/static/images/ask.png"></image> -->
  38. 📝直接提问
  39. </view>
  40. <view class="textarea">
  41. <u--textarea @focus="focustextarea" maxlength="-1" v-model="valuechat" height="100" border="none"
  42. placeholder="您可以向Ai提出任何问题..."></u--textarea>
  43. <view class="operate u-flex align-center">
  44. <view @click="valuechat = ''" class="empty">清空</view>
  45. <view @click="ondraw" v-if="appInfo.is_aipainting&&appInfo.is_aipainting == 1"
  46. style="background: #ffc107;margin-right: 30rpx;border: #ffc107 1px solid;"
  47. hover-class="hoversubmit" class="submit">Ai绘画</view>
  48. <view @click="onSubmit(valuechat)" hover-class="hoversubmit" class="submit">提交问题</view>
  49. </view>
  50. </view>
  51. <view class="askaquestion u-flex align-center justify-between">
  52. <!-- 🔥 -->
  53. <view class="u-flex align-center">
  54. <!-- <image src="/static/images/heat.png"></image> -->
  55. 🔥热门提问
  56. </view>
  57. <view @click="updateTemplate" class="tn-flex align-center"
  58. style="justify-content: flex-end;margin-top: 15rpx;">
  59. <view style="color: #9e9e9e;margin-right: 10rpx;">换一换</view>
  60. <u-icon name="reload" color="#9e9e9e" size="18"></u-icon>
  61. </view>
  62. </view>
  63. <block v-for="(item, index) in homeTemplate.hot" :key="index">
  64. <view class="case" @click="onSubmit(item.text)">{{ item.text }}</view>
  65. </block>
  66. <!-- #ifdef MP-WEIXIN -->
  67. <view class="wxad" v-if="appInfo.wxad_index && appInfo.wxad_index >= 1">
  68. <view style="width: 100%;">
  69. <wike-flow-main :flowtype="appInfo.wxad_index" :banner_id="appInfo.banner_id"
  70. :video_banner_id="appInfo.video_banner_id" :native_id="appInfo.native_id"></wike-flow-main>
  71. </view>
  72. </view>
  73. <!-- #endif -->
  74. <view class="askaquestion u-flex align-center justify-between">
  75. <!-- 🛠️ -->
  76. <view class="u-flex align-center">
  77. <!-- <image src="/static/images/formwork.png"></image> -->
  78. 🛠️提问模板
  79. </view>
  80. <view @click="onhelper" class="tn-flex align-center"
  81. style="justify-content: flex-end;margin-top: 15rpx;">
  82. <view style="color: #9e9e9e;margin-right: 6rpx;">更多</view>
  83. <u-icon name="arrow-right" color="#9e9e9e" size="18"></u-icon>
  84. </view>
  85. </view>
  86. <view style="margin-bottom: 10rpx;" class="u-flex flex-wrap justify-between align-center">
  87. <navigator class="helpme" :url="'/pages/template/detail?id=' + item.id"
  88. v-for="(item, index) in homeTemplate.template" :key="index">
  89. <view class="title">{{ item.title }}</view>
  90. <view class="sub_title">{{ item.sub_title }}</view>
  91. </navigator>
  92. </view>
  93. <wike-ad></wike-ad>
  94. </view>
  95. </view>
  96. <view v-if="appInfo.page_template == 3"></view>
  97. <!-- #ifdef H5 -->
  98. <u-popup :show="h5share" mode="center" @close="h5share = false">
  99. <view class="cu-dialog">
  100. <image class="guide-img" src="http://shopro.7wpp.com/imgs/modal/share_guide.png" mode=""></image>
  101. </view>
  102. </u-popup>
  103. <!-- #endif -->
  104. <!-- <wike-tabbar :onTabbar="onTabbar" :isShowAnimate="isShowAnimate"></wike-tabbar> -->
  105. </view>
  106. </template>
  107. <script>
  108. import {
  109. mapMutations,
  110. mapActions,
  111. mapState,
  112. mapGetters
  113. } from 'vuex';
  114. let interstitialAd = null,
  115. timer,
  116. time2;
  117. export default {
  118. components: {},
  119. data() {
  120. return {
  121. onTabbar: false,
  122. isShowAnimate: false,
  123. valuechat: '',
  124. platform: this.$platform.get(),
  125. h5share: false
  126. };
  127. },
  128. computed: {
  129. ...mapGetters(['appInfo', 'isLogin', 'userInfo', 'homeTemplate', 'userData'])
  130. },
  131. watch: {
  132. appInfo: function(e) {
  133. let that = this;
  134. uni.setNavigationBarTitle({
  135. title: that.appInfo.site_name
  136. });
  137. }
  138. },
  139. onLoad() {
  140. var that = this;
  141. uni.getSystemInfo({
  142. success: function(res) {}
  143. });
  144. setTimeout(() => {
  145. that.onTabbar = true;
  146. that.isShowAnimate = true;
  147. }, 500);
  148. },
  149. onReady() {
  150. let that = this;
  151. // #ifdef MP-WEIXIN
  152. clearTimeout(timer);
  153. // 在适合的场景显示插屏广告
  154. timer = setTimeout(function() {
  155. // 在页面onLoad回调事件中创建插屏广告实例
  156. if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
  157. interstitialAd = wx.createInterstitialAd({
  158. adUnitId: that.appInfo.interstitial_id
  159. });
  160. interstitialAd.onLoad(() => {});
  161. interstitialAd.onError(err => {});
  162. interstitialAd.onClose(() => {
  163. if (that.appInfo.interstitial_infinite_status == 1) {
  164. that.showInterstitial();
  165. }
  166. });
  167. interstitialAd.show().catch(err => {
  168. console.error(err);
  169. });
  170. }
  171. }, 4000);
  172. // #endif
  173. },
  174. onShow() {
  175. if (this.isLogin) {
  176. this.getUserData();
  177. }
  178. },
  179. onUnload() {
  180. clearInterval(time2);
  181. },
  182. methods: {
  183. ...mapActions(['appInit', 'logout', 'getUserInfo', 'getUserData']),
  184. init() {
  185. var that = this;
  186. return Promise.all([this.appInit()]).then(res => {
  187. });
  188. },
  189. showInterstitial() {
  190. time2 = setInterval(
  191. function() {
  192. interstitialAd.show().catch(err => {
  193. console.error(err);
  194. });
  195. },
  196. this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
  197. );
  198. },
  199. updateTemplate() {
  200. this.$store.dispatch('getTemplate');
  201. },
  202. onToForm() {
  203. uni.navigateTo({
  204. url: '/pages/chat/chat'
  205. });
  206. },
  207. onhelper() {
  208. uni.switchTab({
  209. url: '/pages/template/template'
  210. });
  211. },
  212. focustextarea() {
  213. if (!this.isLogin) {
  214. uni.navigateTo({
  215. url: '/pages/user/signin'
  216. });
  217. uni.setStorageSync('route', '/pages/index/index');
  218. return;
  219. }
  220. },
  221. ondraw() {
  222. uni.navigateTo({
  223. url: '/pages/chat/chat?draw=1'
  224. });
  225. },
  226. onSubmit(e) {
  227. // console.log(e);
  228. var that = this;
  229. if (!that.isLogin) {
  230. uni.navigateTo({
  231. url: '/pages/user/signin'
  232. });
  233. uni.setStorageSync('route', '/pages/index/index');
  234. return;
  235. }
  236. if (!e) {
  237. uni.showToast({
  238. title: '请输入关键词或问题',
  239. icon: 'none'
  240. });
  241. return;
  242. }
  243. if (that.userData.is_validity == 0 && that.userData.coin <= 0) {
  244. var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
  245. uni.showModal({
  246. confirmText: '立即获取',
  247. confirmColor: '#26B3A0',
  248. content: '您的提问' + alias + '/会员时长不足',
  249. title: '提示',
  250. success(res) {
  251. if (res.confirm) {
  252. uni.navigateTo({
  253. url: '/pages/user/member/member'
  254. });
  255. }
  256. }
  257. });
  258. return;
  259. }
  260. uni.navigateTo({
  261. url: '/pages/chat/chat?question=' + e
  262. });
  263. that.valuechat = ''
  264. }
  265. }
  266. };
  267. </script>
  268. <style lang="scss">
  269. @import './index.scss';
  270. .container {
  271. // margin-top: 25%;
  272. }
  273. .top-notice {
  274. position: fixed;
  275. top: 0;
  276. left: 0;
  277. width: 100%;
  278. }
  279. .form {
  280. display: flex;
  281. flex-direction: column;
  282. align-items: center;
  283. justify-content: center;
  284. margin-top: 15%;
  285. .title {
  286. font-size: 38rpx;
  287. font-weight: bolder;
  288. // margin-top: 15rpx;
  289. margin: 15rpx 35rpx 0;
  290. }
  291. .desc {
  292. // margin-top: 15rpx;
  293. font-size: 28rpx;
  294. color: #666;
  295. margin: 15rpx 35rpx;
  296. }
  297. .btn-group {
  298. width: 80%;
  299. // margin-top: 26%;
  300. // margin-bottom: 42%;
  301. position: absolute;
  302. bottom: 80px;
  303. padding-bottom: env(safe-area-inset-bottom);
  304. .btn {
  305. margin: 30rpx 0rpx;
  306. .u-button {
  307. height: 100rpx;
  308. }
  309. }
  310. }
  311. }
  312. .directask {
  313. padding: 30rpx 30rpx 200rpx;
  314. border-top: 1px solid #ededed;
  315. .askaquestion {
  316. font-size: 32rpx;
  317. margin-bottom: 25rpx;
  318. image {
  319. width: 32rpx;
  320. height: 32rpx;
  321. margin-right: 12rpx;
  322. }
  323. }
  324. .textarea {
  325. box-shadow: 0px 0px 10px 5px #9e9e9e36;
  326. margin-top: 30rpx;
  327. margin-bottom: 30rpx;
  328. border-radius: 20rpx;
  329. padding: 20rpx 30rpx 30rpx 12rpx;
  330. .u-textarea {
  331. border-radius: 20rpx;
  332. }
  333. .operate {
  334. justify-content: flex-end;
  335. .empty {
  336. margin-right: 30rpx;
  337. border: 1px solid #9e9e9e;
  338. color: #9e9e9e;
  339. padding: 12rpx 42rpx;
  340. border-radius: 10rpx;
  341. }
  342. .submit {
  343. padding: 12rpx 42rpx;
  344. border-radius: 10rpx;
  345. border: 1px solid #26b3a0;
  346. background: #26b3a0;
  347. color: #fff;
  348. }
  349. .hoversubmit {
  350. background: #f7f7f7;
  351. color: #acacb3;
  352. }
  353. }
  354. }
  355. .case {
  356. color: #26b3a0;
  357. background: #f5f8f7;
  358. width: 100%;
  359. height: 80rpx;
  360. line-height: 80rpx;
  361. font-size: 30rpx;
  362. padding-left: 30rpx;
  363. border-radius: 10rpx;
  364. margin: 25rpx 0;
  365. border-radius: 10rpx;
  366. overflow: hidden;
  367. display: -webkit-box !important;
  368. text-overflow: ellipsis;
  369. word-break: break-all;
  370. -webkit-line-clamp: 1;
  371. -webkit-box-orient: vertical !important;
  372. }
  373. .helpme {
  374. background: #f5f8f7;
  375. border-radius: 20rpx;
  376. padding: 30rpx;
  377. width: 48%;
  378. margin-bottom: 25rpx;
  379. height: 92px;
  380. .title {
  381. font-size: 30rpx;
  382. font-weight: bold;
  383. margin-bottom: 18rpx;
  384. color: #000;
  385. overflow: hidden;
  386. text-overflow: ellipsis;
  387. white-space: nowrap
  388. }
  389. .sub_title {
  390. color: #8f9ca2;
  391. font-size: 24rpx;
  392. overflow: hidden;
  393. text-overflow: ellipsis;
  394. display: -webkit-box;
  395. -webkit-box-orient: vertical;
  396. -webkit-line-clamp: 2;
  397. }
  398. }
  399. }
  400. .wxad {
  401. border-radius: 20rpx;
  402. overflow: hidden;
  403. margin-bottom: 24rpx;
  404. }
  405. .cu-dialog {
  406. position: fixed;
  407. top: 60rpx;
  408. left: 100rpx;
  409. // background: #000000;
  410. }
  411. .guide-img {
  412. width: 580rpx;
  413. height: 430rpx;
  414. }
  415. </style>