index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view class="container">
  3. <!-- <wike-skeleton :count="4" v-if="homeTemplate.length === 0"></wike-skeleton> -->
  4. <view>
  5. <view class="directask">
  6. <!-- 📝 -->
  7. <view class="askaquestion u-flex align-center">
  8. <!-- <image src="/static/images/ask.png"></image> -->
  9. 📝直接提问</view>
  10. <view class="textarea">
  11. <u--textarea @focus="focustextarea" maxlength="-1" v-model="valuechat" height="100" border="none"
  12. placeholder="您可以向Ai提出任何问题..."></u--textarea>
  13. <view class="operate u-flex align-center">
  14. <view @click="valuechat = ''" class="empty">清空</view>
  15. <view @click="ondraw" v-if="appInfo.is_aipainting&&appInfo.is_aipainting == 1" style="background: #ffc107;margin-right: 30rpx;border: #ffc107 1px solid;" hover-class="hoversubmit" class="submit">Ai绘画</view>
  16. <view @click="onSubmit(valuechat)" hover-class="hoversubmit" class="submit">提交问题</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. mapMutations,
  26. mapActions,
  27. mapState,
  28. mapGetters
  29. } from 'vuex';
  30. let interstitialAd = null,
  31. timer,
  32. time2;
  33. export default {
  34. components: {},
  35. data() {
  36. return {
  37. onTabbar: false,
  38. isShowAnimate: false,
  39. valuechat: '',
  40. platform: this.$platform.get(),
  41. h5share: false
  42. };
  43. },
  44. computed: {
  45. ...mapGetters(['appInfo', 'isLogin', 'userInfo', 'homeTemplate', 'userData'])
  46. },
  47. watch: {
  48. appInfo: function(e) {
  49. let that = this;
  50. uni.setNavigationBarTitle({
  51. title: that.appInfo.site_name
  52. });
  53. }
  54. },
  55. onLoad() {
  56. var that = this;
  57. uni.getSystemInfo({
  58. success: function(res) {}
  59. });
  60. setTimeout(() => {
  61. that.onTabbar = true;
  62. that.isShowAnimate = true;
  63. }, 500);
  64. },
  65. onReady() {
  66. let that = this;
  67. // #ifdef MP-WEIXIN
  68. clearTimeout(timer);
  69. // 在适合的场景显示插屏广告
  70. timer = setTimeout(function() {
  71. // 在页面onLoad回调事件中创建插屏广告实例
  72. if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
  73. interstitialAd = wx.createInterstitialAd({
  74. adUnitId: that.appInfo.interstitial_id
  75. });
  76. interstitialAd.onLoad(() => {});
  77. interstitialAd.onError(err => {});
  78. interstitialAd.onClose(() => {
  79. if (that.appInfo.interstitial_infinite_status == 1) {
  80. that.showInterstitial();
  81. }
  82. });
  83. interstitialAd.show().catch(err => {
  84. console.error(err);
  85. });
  86. }
  87. }, 4000);
  88. // #endif
  89. },
  90. onShow() {
  91. if (this.isLogin) {
  92. this.getUserData();
  93. }
  94. },
  95. onUnload() {
  96. clearInterval(time2);
  97. },
  98. methods: {
  99. ...mapActions(['appInit', 'logout', 'getUserInfo', 'getUserData']),
  100. init() {
  101. var that = this;
  102. return Promise.all([this.appInit()]).then(res => {
  103. });
  104. },
  105. showInterstitial() {
  106. time2 = setInterval(
  107. function() {
  108. interstitialAd.show().catch(err => {
  109. console.error(err);
  110. });
  111. },
  112. this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
  113. );
  114. },
  115. updateTemplate() {
  116. this.$store.dispatch('getTemplate');
  117. },
  118. onToForm() {
  119. uni.navigateTo({
  120. url: '/pages/chat/chat'
  121. });
  122. },
  123. onhelper() {
  124. uni.switchTab({
  125. url: '/pages/template/template'
  126. });
  127. },
  128. focustextarea() {
  129. },
  130. ondraw(){
  131. uni.navigateTo({
  132. url: '/pages/chat/chat?draw=1'
  133. });
  134. },
  135. onSubmit(e) {
  136. // console.log(e);
  137. var that = this;
  138. if (!e) {
  139. uni.showToast({
  140. title: '请输入关键词或问题',
  141. icon: 'none'
  142. });
  143. return;
  144. }
  145. uni.navigateTo({
  146. url: '/pages/chat/chat?question=' + e
  147. });
  148. that.valuechat = ''
  149. }
  150. }
  151. };
  152. </script>
  153. <style lang="scss">
  154. .container{
  155. // margin-top: 25%;
  156. }
  157. .top-notice {
  158. position: fixed;
  159. top: 0;
  160. left: 0;
  161. width: 100%;
  162. }
  163. .form {
  164. display: flex;
  165. flex-direction: column;
  166. align-items: center;
  167. justify-content: center;
  168. margin-top: 15%;
  169. .title {
  170. font-size: 38rpx;
  171. font-weight: bolder;
  172. // margin-top: 15rpx;
  173. margin: 15rpx 35rpx 0;
  174. }
  175. .desc {
  176. // margin-top: 15rpx;
  177. font-size: 28rpx;
  178. color: #666;
  179. margin: 15rpx 35rpx;
  180. }
  181. .btn-group {
  182. width: 80%;
  183. // margin-top: 26%;
  184. // margin-bottom: 42%;
  185. position: absolute;
  186. bottom: 80px;
  187. padding-bottom: env(safe-area-inset-bottom);
  188. .btn {
  189. margin: 30rpx 0rpx;
  190. .u-button {
  191. height: 100rpx;
  192. }
  193. }
  194. }
  195. }
  196. .directask {
  197. padding: 30rpx 30rpx 200rpx;
  198. border-top: 1px solid #ededed;
  199. .askaquestion {
  200. font-size: 32rpx;
  201. margin-bottom: 25rpx;
  202. image{
  203. width: 32rpx;
  204. height: 32rpx;
  205. margin-right: 12rpx;
  206. }
  207. }
  208. .textarea {
  209. box-shadow: 0px 0px 10px 5px #9e9e9e36;
  210. margin-top: 30rpx;
  211. margin-bottom: 30rpx;
  212. border-radius: 20rpx;
  213. padding: 20rpx 30rpx 30rpx 12rpx;
  214. .u-textarea {
  215. border-radius: 20rpx;
  216. }
  217. .operate {
  218. justify-content: flex-end;
  219. .empty {
  220. margin-right: 30rpx;
  221. border: 1px solid #9e9e9e;
  222. color: #9e9e9e;
  223. padding: 12rpx 42rpx;
  224. border-radius: 10rpx;
  225. }
  226. .submit {
  227. padding: 12rpx 42rpx;
  228. border-radius: 10rpx;
  229. border: 1px solid #26b3a0;
  230. background: #26b3a0;
  231. color: #fff;
  232. }
  233. .hoversubmit {
  234. background: #f7f7f7;
  235. color: #acacb3;
  236. }
  237. }
  238. }
  239. .case {
  240. color: #26b3a0;
  241. background: #f5f8f7;
  242. width: 100%;
  243. height: 80rpx;
  244. line-height: 80rpx;
  245. font-size: 30rpx;
  246. padding-left: 30rpx;
  247. border-radius: 10rpx;
  248. margin: 25rpx 0;
  249. border-radius: 10rpx;
  250. overflow: hidden;
  251. display: -webkit-box !important;
  252. text-overflow: ellipsis;
  253. word-break: break-all;
  254. -webkit-line-clamp: 1;
  255. -webkit-box-orient: vertical !important;
  256. }
  257. .helpme {
  258. background: #f5f8f7;
  259. border-radius: 20rpx;
  260. padding: 30rpx;
  261. width: 48%;
  262. margin-bottom: 25rpx;
  263. height: 92px;
  264. .title {
  265. font-size: 30rpx;
  266. font-weight: bold;
  267. margin-bottom: 18rpx;
  268. color: #000;
  269. overflow:hidden; text-overflow:ellipsis; white-space:nowrap
  270. }
  271. .sub_title {
  272. color: #8f9ca2;
  273. font-size: 24rpx;
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. display: -webkit-box;
  277. -webkit-box-orient: vertical;
  278. -webkit-line-clamp: 2;
  279. }
  280. }
  281. }
  282. .wxad {
  283. border-radius: 20rpx;
  284. overflow: hidden;
  285. margin-bottom: 24rpx;
  286. }
  287. .cu-dialog {
  288. position: fixed;
  289. top: 60rpx;
  290. left: 100rpx;
  291. // background: #000000;
  292. }
  293. .guide-img {
  294. width: 580rpx;
  295. height: 430rpx;
  296. }
  297. </style>