Browse Source

初始化项目

黎海 2 years ago
commit
2bb64c27f6

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
1
+dist/
2
+deploy_versions/
3
+.temp/
4
+.rn_temp/
5
+node_modules/
6
+.DS_Store

+ 10 - 0
babel.config.js

@@ -0,0 +1,10 @@
1
+// babel-preset-taro 更多选项和默认值:
2
+// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3
+module.exports = {
4
+  presets: [
5
+    ['taro', {
6
+      framework: 'react',
7
+      ts: false
8
+    }]
9
+  ]
10
+}

+ 9 - 0
config/dev.js

@@ -0,0 +1,9 @@
1
+module.exports = {
2
+  env: {
3
+    NODE_ENV: '"development"'
4
+  },
5
+  defineConstants: {
6
+  },
7
+  mini: {},
8
+  h5: {}
9
+}

+ 82 - 0
config/index.js

@@ -0,0 +1,82 @@
1
+const config = {
2
+  projectName: 'myApp',
3
+  date: '2023-3-2',
4
+  designWidth: 750,
5
+  deviceRatio: {
6
+    640: 2.34 / 2,
7
+    750: 1,
8
+    828: 1.81 / 2
9
+  },
10
+  sourceRoot: 'src',
11
+  outputRoot: 'dist',
12
+  plugins: [],
13
+  defineConstants: {
14
+  },
15
+  copy: {
16
+    patterns: [
17
+    ],
18
+    options: {
19
+    }
20
+  },
21
+  framework: 'react',
22
+  compiler: 'webpack5',
23
+  cache: {
24
+    enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
25
+  },
26
+  mini: {
27
+    postcss: {
28
+      pxtransform: {
29
+        enable: true,
30
+        config: {
31
+
32
+        }
33
+      },
34
+      url: {
35
+        enable: true,
36
+        config: {
37
+          limit: 1024 // 设定转换尺寸上限
38
+        }
39
+      },
40
+      cssModules: {
41
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
42
+        config: {
43
+          namingPattern: 'module', // 转换模式,取值为 global/module
44
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
45
+        }
46
+      }
47
+    }
48
+  },
49
+  h5: {
50
+    publicPath: '/',
51
+    staticDirectory: 'static',
52
+    postcss: {
53
+      autoprefixer: {
54
+        enable: true,
55
+        config: {
56
+        }
57
+      },
58
+      cssModules: {
59
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
60
+        config: {
61
+          namingPattern: 'module', // 转换模式,取值为 global/module
62
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
63
+        }
64
+      }
65
+    }
66
+  },
67
+  rn: {
68
+    appName: 'taroDemo',
69
+    postcss: {
70
+      cssModules: {
71
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
72
+      }
73
+    }
74
+  }
75
+}
76
+
77
+module.exports = function (merge) {
78
+  if (process.env.NODE_ENV === 'development') {
79
+    return merge({}, config, require('./dev'))
80
+  }
81
+  return merge({}, config, require('./prod'))
82
+}

+ 37 - 0
config/prod.js

@@ -0,0 +1,37 @@
1
+module.exports = {
2
+  env: {
3
+    NODE_ENV: '"production"'
4
+  },
5
+  defineConstants: {
6
+  },
7
+  mini: {},
8
+  h5: {
9
+    /**
10
+     * WebpackChain 插件配置
11
+     * @docs https://github.com/neutrinojs/webpack-chain
12
+     */
13
+    // webpackChain (chain) {
14
+    //   /**
15
+    //    * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
16
+    //    * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
17
+    //    */
18
+    //   chain.plugin('analyzer')
19
+    //     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
20
+
21
+    //   /**
22
+    //    * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
23
+    //    * @docs https://github.com/chrisvfritz/prerender-spa-plugin
24
+    //    */
25
+    //   const path = require('path')
26
+    //   const Prerender = require('prerender-spa-plugin')
27
+    //   const staticDir = path.join(__dirname, '..', 'dist')
28
+    //   chain
29
+    //     .plugin('prerender')
30
+    //     .use(new Prerender({
31
+    //       staticDir,
32
+    //       routes: [ '/pages/index/index' ],
33
+    //       postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
34
+    //     }))
35
+    // }
36
+  }
37
+}

File diff suppressed because it is too large
+ 17457 - 0
package-lock.json


+ 74 - 0
package.json

@@ -0,0 +1,74 @@
1
+{
2
+  "name": "myApp",
3
+  "version": "1.0.0",
4
+  "private": true,
5
+  "description": "liaotian ",
6
+  "templateInfo": {
7
+    "name": "default",
8
+    "typescript": false,
9
+    "css": "less"
10
+  },
11
+  "scripts": {
12
+    "build:weapp": "taro build --type weapp",
13
+    "build:swan": "taro build --type swan",
14
+    "build:alipay": "taro build --type alipay",
15
+    "build:tt": "taro build --type tt",
16
+    "build:h5": "taro build --type h5",
17
+    "build:rn": "taro build --type rn",
18
+    "build:qq": "taro build --type qq",
19
+    "build:jd": "taro build --type jd",
20
+    "build:quickapp": "taro build --type quickapp",
21
+    "dev:weapp": "npm run build:weapp -- --watch",
22
+    "dev:swan": "npm run build:swan -- --watch",
23
+    "dev:alipay": "npm run build:alipay -- --watch",
24
+    "dev:tt": "npm run build:tt -- --watch",
25
+    "dev:h5": "npm run build:h5 -- --watch",
26
+    "dev:rn": "npm run build:rn -- --watch",
27
+    "dev:qq": "npm run build:qq -- --watch",
28
+    "dev:jd": "npm run build:jd -- --watch",
29
+    "dev:quickapp": "npm run build:quickapp -- --watch"
30
+  },
31
+  "browserslist": [
32
+    "last 3 versions",
33
+    "Android >= 4.1",
34
+    "ios >= 8"
35
+  ],
36
+  "author": "",
37
+  "dependencies": {
38
+    "@babel/runtime": "^7.7.7",
39
+    "@tarojs/components": "3.5.7",
40
+    "@tarojs/helper": "3.5.7",
41
+    "@tarojs/plugin-framework-react": "3.5.7",
42
+    "@tarojs/plugin-platform-alipay": "3.5.7",
43
+    "@tarojs/plugin-platform-jd": "3.5.7",
44
+    "@tarojs/plugin-platform-qq": "3.5.7",
45
+    "@tarojs/plugin-platform-swan": "3.5.7",
46
+    "@tarojs/plugin-platform-tt": "3.5.7",
47
+    "@tarojs/plugin-platform-weapp": "3.5.7",
48
+    "@tarojs/react": "3.5.7",
49
+    "@tarojs/router": "3.5.7",
50
+    "@tarojs/runtime": "3.5.7",
51
+    "@tarojs/shared": "3.5.7",
52
+    "@tarojs/taro": "3.5.7",
53
+    "@tarojs/taro-h5": "3.5.7",
54
+    "react": "^18.0.0",
55
+    "react-dom": "^18.0.0"
56
+  },
57
+  "devDependencies": {
58
+    "@babel/core": "^7.8.0",
59
+    "@tarojs/cli": "3.5.7",
60
+    "@types/webpack-env": "^1.13.6",
61
+    "@types/react": "^18.0.0",
62
+    "webpack": "5.69.0",
63
+    "@tarojs/webpack5-runner": "3.5.7",
64
+    "babel-preset-taro": "3.5.7",
65
+    "eslint-config-taro": "3.5.7",
66
+    "eslint": "^8.12.0",
67
+    "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
68
+    "react-refresh": "^0.11.0",
69
+    "eslint-plugin-react": "^7.8.2",
70
+    "eslint-plugin-import": "^2.12.0",
71
+    "eslint-plugin-react-hooks": "^4.2.0",
72
+    "stylelint": "^14.4.0"
73
+  }
74
+}

+ 29 - 0
project.config.json

@@ -0,0 +1,29 @@
1
+{
2
+  "miniprogramRoot": "dist/weapp/",
3
+  "projectname": "畅享短剧",
4
+  "description": "畅享短剧 ",
5
+  "appid": "wxe7aa01162d73df1f",
6
+  "setting": {
7
+    "urlCheck": true,
8
+    "es6": false,
9
+    "postcss": false,
10
+    "minified": false,
11
+    "babelSetting": {
12
+        "ignore": [],
13
+        "disablePlugins": [],
14
+        "outputPath": ""
15
+    }
16
+},
17
+"compileType": "miniprogram",
18
+"libVersion": "2.26.0",
19
+"srcMiniprogramRoot": "dist/",
20
+"packOptions": {
21
+    "ignore": [],
22
+    "include": []
23
+},
24
+"condition": {},
25
+"editorSetting": {
26
+    "tabIndent": "insertSpaces",
27
+    "tabSize": 2
28
+}
29
+}

+ 9 - 0
project.tt.json

@@ -0,0 +1,9 @@
1
+{
2
+  "miniprogramRoot": "./",
3
+  "projectname": "AI智能助手",
4
+  "appid": "tt6e291894f116667e01",
5
+  "setting": {
6
+    "es6": false,
7
+    "minified": false
8
+  }
9
+}

+ 8 - 0
src/api/config.js

@@ -0,0 +1,8 @@
1
+// 配置请求对象
2
+// 本地调试 dev 开发阶段
3
+export const baseUrl = "https://test-openai.fyshark.com";//测试
4
+// export const baseUrl = "https://api-video.fyshz.com";//正式
5
+// product 阶段
6
+// https://www.fastmock.site/mock/3f112f6cb2f621fc9c2dd6a14be19f38/beers/
7
+// 设计模式
8
+

+ 43 - 0
src/api/request.js

@@ -0,0 +1,43 @@
1
+import Taro from '@tarojs/taro';
2
+import {
3
+  baseUrl
4
+} from './config';
5
+
6
+
7
+export default (options = {
8
+  method: 'GET',
9
+  data: {}
10
+}) => {
11
+
12
+  const request_data = {
13
+  };
14
+  return Taro.request({
15
+    url: baseUrl + options.url,
16
+    data: {
17
+      ...request_data,
18
+      ...options.data,
19
+    },
20
+    header: {
21
+      'Content-Type': 'application/json',
22
+      'accept': 'application/json'
23
+    },
24
+    method: options.method.toUpperCase(),
25
+  }).then(res => {
26
+    const {
27
+      statusCode,
28
+      data
29
+    } = res;
30
+    const _res = Taro.getStorageInfoSync()
31
+    let notApiStr = '/api/get_app_config;/api/login;/api/report_login;/api/video/video_detail;/api/pay/get_my_wallet;/api/get_template_list'
32
+    
33
+    if (statusCode == 200) {
34
+      return data;
35
+    } else {
36
+      Taro.showToast({
37
+        title: `${res.msg}~`,
38
+        icon: 'none',
39
+        mask: true,
40
+      });
41
+    }
42
+  });
43
+};

+ 53 - 0
src/app.config.js

@@ -0,0 +1,53 @@
1
+export default defineAppConfig({
2
+  pages: [
3
+    'pages/chat/index',
4
+    'pages/collection/index',
5
+    "pages/task/index",
6
+    "pages/mine/index"
7
+  ],
8
+  window: {
9
+    backgroundTextStyle: 'light',
10
+    navigationBarBackgroundColor: '#fff',
11
+    navigationBarTitleText: 'WeChat',
12
+    navigationBarTextStyle: 'black'
13
+  },
14
+  plugins: {
15
+    "WechatSI": {
16
+      version: '0.3.5',
17
+      provider: 'wx069ba97219f66d99'
18
+    }
19
+  },
20
+  // tabBar: {
21
+  //   color: "#000000",
22
+  //   selectedColor: "#FF5819",
23
+  //   borderStyle: "white",
24
+  //   backgroundColor: "#fff",
25
+  //   list: [
26
+  //     {
27
+  //       pagePath: "pages/collection/index",
28
+  //       iconPath: "images/nav/like.png",
29
+  //       selectedIconPath: "images/nav/like_pin.png",
30
+  //       text: "收藏"
31
+
32
+  //     },
33
+  //     {
34
+  //       pagePath: "pages/chat/index",
35
+  //       iconPath: "images/nav/play.png",
36
+  //       selectedIconPath: "images/nav/play_pin.png",
37
+  //       text: "首页"
38
+  //     },
39
+  //     {
40
+  //       pagePath: "pages/task/index",
41
+  //       iconPath: "images/nav/task.png",
42
+  //       selectedIconPath: "images/nav/task_pin.png",
43
+  //       text: "领福利"
44
+  //     },
45
+  //     {
46
+  //       pagePath: "pages/mine/index",
47
+  //       iconPath: "images/nav/my.png",
48
+  //       selectedIconPath: "images/nav/my_pin.png",
49
+  //       text: "我的"
50
+  //     }
51
+  //   ]
52
+  // },
53
+})

+ 20 - 0
src/app.js

@@ -0,0 +1,20 @@
1
+import { Component } from 'react'
2
+import './app.less'
3
+
4
+class App extends Component {
5
+
6
+  componentDidMount () {}
7
+
8
+  componentDidShow () {
9
+    console.log('app启动');
10
+  }
11
+
12
+  componentDidHide () {}
13
+
14
+  render () {
15
+    // this.props.children 是将要会渲染的页面
16
+    return this.props.children
17
+  }
18
+}
19
+
20
+export default App

+ 0 - 0
src/app.less


+ 23 - 0
src/common/tool.js

@@ -0,0 +1,23 @@
1
+import Taro from '@tarojs/taro'
2
+const tool = {
3
+  // 生成四位随机数的函数
4
+  generateRandomNumber () {
5
+    // 生成一个 0 到 9999 之间的随机整数
6
+    const randomNumber = Math.floor(Math.random() * 10000);
7
+    // 如果随机数不足四位,则在前面补零
8
+    return randomNumber.toString().padStart(4, '0');
9
+  },
10
+
11
+  // 生成用户ID的函数
12
+  generateUserID () {
13
+    // 获取当前时间戳
14
+    const timestamp = Date.now().toString();
15
+    // 生成四位随机数
16
+    const randomNumber = this.generateRandomNumber();
17
+    // 将时间戳和随机数拼接起来,得到用户ID
18
+    const userID = timestamp + randomNumber;
19
+    console.log(userID,'userID');
20
+    return userID;
21
+  }
22
+}
23
+export default tool

BIN
src/images/app-icon.png


BIN
src/images/nav/like.png


BIN
src/images/nav/like_pin.png


BIN
src/images/nav/my.png


BIN
src/images/nav/my_pin.png


BIN
src/images/nav/play.png


BIN
src/images/nav/play_pin.png


BIN
src/images/nav/task.png


BIN
src/images/nav/task_pin.png


+ 17 - 0
src/index.html

@@ -0,0 +1,17 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
5
+  <meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
6
+  <meta name="apple-mobile-web-app-capable" content="yes">
7
+  <meta name="apple-touch-fullscreen" content="yes">
8
+  <meta name="format-detection" content="telephone=no,address=no">
9
+  <meta name="apple-mobile-web-app-status-bar-style" content="white">
10
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
11
+  <title>myApp</title>
12
+  <script><%= htmlWebpackPlugin.options.script %></script>
13
+</head>
14
+<body>
15
+  <div id="app"></div>
16
+</body>
17
+</html>

+ 5 - 0
src/pages/chat/index.config.js

@@ -0,0 +1,5 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '智能聊天室',
3
+  enableShareAppMessage: true,
4
+  enableShareTimeline: true ,
5
+})

+ 350 - 0
src/pages/chat/index.jsx

@@ -0,0 +1,350 @@
1
+import { Component } from 'react'
2
+import { View, Text, Button, Image, ScrollView, Input, Textarea } from '@tarojs/components'
3
+import Taro, { requirePlugin } from '@tarojs/taro'
4
+import * as api from '../../service/index'
5
+import './index.less'
6
+import tool from '../../common/tool'
7
+
8
+export default class Albums_play extends Component {
9
+  plugin = requirePlugin("WechatSI");
10
+  manager = this.plugin.getRecordRecognitionManager();
11
+  options = {
12
+    sampleRate: 44100,
13
+    numberOfChannels: 1,
14
+    encodeBitRate: 192000,
15
+    format: 'aac'
16
+  }
17
+
18
+  state = {
19
+    login: false,
20
+    sendDisabled: true,//是否禁用发送按钮
21
+    value: '',
22
+    height: 63,
23
+    userId: tool.generateUserID(),
24
+    isAnswer: true,//机器人是否已经回答
25
+    isRecognize: false,
26
+    showResult: false,
27
+    isSpeechSounds: false,//是否是语音写入
28
+    conversations: [
29
+      {
30
+        name: 'other',
31
+        userImage: "https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1677832835490.png",
32
+        userTexts: '您好,我是智能助手,一个由AI训练的聊天机器人。作为一名智能助手,我可以帮助您回答问题,提供建议,分享知识和技能等等。我拥有处理多种自然语言任务的能力,包括自然语言理解和生成,语言翻译,文本摘要和语言生成等等。无论您需要寻求帮助还是只是想进行友好的聊天,我都很乐意与您交流。'
33
+      },
34
+    ]
35
+  }
36
+
37
+  componentDidShow () {
38
+    console.log('页面启动',this.state.userId);
39
+    this.userinfo()
40
+    this.initRecord()
41
+    // this.setState({
42
+    //   userId: this.generateUserID()
43
+    // })
44
+  }
45
+  // useShareAppMessage((res) => {
46
+  //   console.log(res, 'ressss');
47
+  //   let shareData = {
48
+  //     title: `海量好剧,你爱看的都在这里!`,
49
+  //     path: `pages/theatre/index`,  // 分享的路径
50
+  //     // imageUrl: this.props.albums.video.img,  // 分享的图片链接
51
+  //   }
52
+  //   return shareData;
53
+  // })
54
+
55
+  // /**
56
+  //  * 分享朋友圈
57
+  //  * */
58
+  // useShareTimeline((res) => {
59
+  //   let shareData = {
60
+  //     title: `海量好剧,你爱看的都在这里!`,
61
+  //     path: `pages/theatre/index`,  // 分享的路径
62
+  //     // imageUrl: this.props.albums.video.img,  // 分享的图片链接
63
+  //   }
64
+  //   return shareData;
65
+  // })
66
+
67
+  componentDidHide () { }
68
+  
69
+  // 获取用户信息并且登录,获取openid
70
+  userinfo () {
71
+    var that = this;
72
+    that.setState({
73
+      login: false
74
+    })
75
+    Taro.getUserInfo({
76
+      success: function (res) {
77
+        console.log(res, 'userinfo');
78
+        var userInfo = res.userInfo
79
+        var nickName = userInfo.nickName
80
+        var avatarUrl = userInfo.avatarUrl
81
+        var gender = userInfo.gender //性别 0:未知、1:男、2:女
82
+        var province = userInfo.province
83
+        var city = userInfo.city
84
+        var country = userInfo.country
85
+        let data = {
86
+          "user_name": nickName,
87
+          "user_img": avatarUrl
88
+        };
89
+      }
90
+    })
91
+  }
92
+  // 提交文字
93
+  submitTo () {
94
+    let inputHtml = document.getElementById('advice_textarea').props.value
95
+    if (inputHtml.length == 0) return
96
+    this.sendText(inputHtml)
97
+
98
+  }
99
+  sendText (inputHtml) {
100
+    console.log(inputHtml, 'inputHtml');
101
+    let textObj = {
102
+      name: 'mine',
103
+      userImage: "https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1677833953396.jpeg",
104
+      userTexts: inputHtml
105
+    }
106
+    this.state.conversations.push(textObj)
107
+    this.setState({
108
+      sendDisabled: true,
109
+      value: '',
110
+      isAnswer: false
111
+    })
112
+    let params = {
113
+      user_id: this.state.userId,
114
+      text: inputHtml
115
+    }
116
+    api.getAsk(params).then(res => {
117
+      if (res.code == 200) {
118
+        let otherInfo = {
119
+          name: 'other',
120
+          userImage: "https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1677832835490.png",
121
+          userTexts: res.data
122
+        }
123
+        this.state.conversations.push(otherInfo)
124
+        this.setState({
125
+          isAnswer: true,
126
+          value: ''
127
+        })
128
+      } else {
129
+        this.setState({
130
+          sendDisabled: true,//是否禁用发送按钮
131
+          value: '',
132
+          height: 63,
133
+          userId: 0,
134
+          isAnswer: true,//机器人是否已经回答
135
+          isRecognize: false,
136
+          showResult: false,
137
+          isSpeechSounds: false,//是否是语音写入
138
+        })
139
+      }
140
+    })
141
+    .catch(res=>{
142
+      console.log("请求超时");
143
+      this.setState({
144
+        sendDisabled: true,//是否禁用发送按钮
145
+        value: '',
146
+        height: 63,
147
+        userId: 0,
148
+        isAnswer: true,//机器人是否已经回答
149
+        isRecognize: false,
150
+        showResult: false,
151
+        isSpeechSounds: false,//是否是语音写入
152
+      })
153
+    })
154
+  }
155
+  //文字输入
156
+  focus (e) {
157
+    let inputHtml = document.getElementById('advice_textarea').props.value
158
+    this.setState({
159
+      sendDisabled: false,
160
+      value: inputHtml
161
+    })
162
+  }
163
+  blur (e) {
164
+    // this.setState({
165
+    //   sendDisabled: true
166
+    // })
167
+  }
168
+  //键盘高度发生变换时
169
+  onKeyboardHeightChange (e) {
170
+    console.log(e, 'onKeyboardHeightChange');
171
+  }
172
+  onLineChange (e) {
173
+    console.log(e, 'onLineChange');
174
+  }
175
+  changeSpeak () {
176
+    if (!this.state.isAnswer) return
177
+    this.setState({
178
+      isSpeechSounds: !this.state.isSpeechSounds
179
+    })
180
+  }
181
+  // 初始化语音识别
182
+  initRecord () {
183
+    let that = this
184
+    console.log('initRecord');
185
+    this.manager.onRecognize = (res) => {
186
+      console.log("current result", res.result);
187
+    };
188
+    // 识别错误事件
189
+    this.manager.onError = function (res) {
190
+      Taro.hideLoading();
191
+    }
192
+    this.manager.onStop = (res) => {
193
+      Taro.hideLoading();
194
+      // 去除语音识别出的特殊符号
195
+      const text = res.result.replace(
196
+        /[`~%!@#^=''?~《》!@#¥……&——‘”“'?*()(),,。.、<>]/g,
197
+        ""
198
+      );
199
+      console.log(text, 'text');
200
+      if (text) {
201
+        that.sendText(text)
202
+        that.setState({
203
+          value: text
204
+        })
205
+        // 识别结果展示1.5秒后收起                               
206
+        setTimeout(() => {
207
+          that.setState({
208
+            isRecognize: false,
209
+            showResult: false,
210
+          })
211
+
212
+        }, 1500);
213
+      } else {
214
+
215
+        setTimeout(() => {
216
+          that.setState({
217
+            isRecognize: false,
218
+            showResult: false,
219
+          })
220
+        }, 1500);
221
+      }
222
+      that.setState({
223
+        showResult: true
224
+      })
225
+    };
226
+    this.manager.onError = (res) => {
227
+      Taro.hideLoading();
228
+      if (res.msg) {
229
+        Taro.showToast({ title: res.msg, icon: "none" });
230
+      }
231
+    };
232
+  };
233
+  // 开始录音
234
+  startRecognize = () => {
235
+    wx.vibrateShort()
236
+    Taro.showLoading({ title: "录音中..." });
237
+    this.setState({
238
+      isRecognize: true,
239
+      value: '',
240
+    })
241
+    this.manager.start({ duration: 30000, lang: "zh_CN" });
242
+  };
243
+  // 结束录音
244
+  endRecognize = () => {
245
+    console.log("endRecognize");
246
+    Taro.hideLoading();
247
+    Taro.showLoading({ title: "识别中..." });
248
+    this.manager.stop();
249
+
250
+  };
251
+
252
+  render () {
253
+    return (
254
+      <View className='mine'>
255
+        <ScrollView
256
+          className='scrollview'
257
+          style={`max-height: calc(100vh - ${this.state.height}px);`}
258
+          scrollY
259
+          scrollIntoView={`scrollIntoView_${this.state.conversations.length}`}
260
+          scrollWithAnimation
261
+          lowerThreshold="20"
262
+          upperThreshold="20"
263
+
264
+        >
265
+          {
266
+            this.state.conversations.map((item, index) => (
267
+              <View key={index} id={`scrollIntoView_${index + 1}`}>
268
+                {
269
+                  item.name == 'mine' &&
270
+                  <View className='mine-speak-info'>
271
+                    <View className='mine-text'>
272
+                      <Text selectable className='mine-text-content'>
273
+                        {item.userTexts}
274
+                      </Text>
275
+                      <View className='mine-text-tip'></View>
276
+                    </View>
277
+                    <Image className='mine-image' src={item.userImage}></Image>
278
+                  </View>
279
+                }
280
+                {
281
+                  item.name == 'other' &&
282
+                  <View className='other-speak-info'>
283
+                    <Image className='other-image' src={item.userImage}></Image>
284
+                    <View className='other-text'>
285
+                      <Text selectable className='other-text-content'>
286
+                        {item.userTexts}
287
+                      </Text>
288
+                      <View className='other-text-tip'></View>
289
+                    </View>
290
+                  </View>
291
+                }
292
+              </View>
293
+
294
+            ))
295
+          }
296
+
297
+        </ScrollView>
298
+        <View className="in_voice_icon">
299
+          {
300
+            !this.state.isAnswer &&
301
+            <View className='in_voice_icon_tips'>机器人思考中...</View>
302
+          }
303
+          <View className="sendmessage" style={`bottom:${this.state.input_bottom}px`}>
304
+            <Image className='add_icon' style={!this.state.isAnswer ? 'opacity: .3;' : ''} onClick={e => (this.changeSpeak(e))} id='1' src='https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1677739244529.png'></Image>
305
+            {
306
+              this.state.isSpeechSounds ?
307
+                <View
308
+                  className="recognize-btn view-center"
309
+                  onClick={() => {
310
+                    // 按住按钮时间过短只会触发点击事件
311
+                    Taro.hideLoading();
312
+                    Taro.showToast({ title: "请长按说话", icon: "error" });
313
+                  }}
314
+                  onLongPress={e => (this.startRecognize())}
315
+                  onTouchEnd={e => (this.endRecognize())}
316
+                >
317
+                  <View>
318
+                    {this.state.isRecognize
319
+                      ? "松开发送"
320
+                      : "按住说话"}
321
+                  </View>
322
+                </View>
323
+                :
324
+                <Input
325
+                  autoHeight
326
+                  disabled={!this.state.isAnswer}
327
+                  id='advice_textarea'
328
+                  cursorSpacing='5'
329
+                  showConfirmBar=''
330
+                  confirmType='send'
331
+                  onConfirm={e => (this.submitTo(e))}
332
+                  adjustPosition
333
+                  value={this.state.value}
334
+                  onFocus={e => (this.focus(e))}
335
+                  onBlur={e => (this.blur(e))}
336
+                  onKeyboardHeightChange={e => (this.onKeyboardHeightChange(e))}
337
+                  onLineChange={e => (this.onLineChange(e))}
338
+                  placeholder="请输入您要咨询的问题" />
339
+            }
340
+
341
+            <Button onClick={e => (this.submitTo(e))}
342
+              disabled={this.state.sendDisabled}
343
+              style={this.state.sendDisabled ? 'opacity: .3;' : ''}
344
+              className='user_input_Text'>发送</Button>
345
+          </View>
346
+        </View>
347
+      </View>
348
+    )
349
+  }
350
+}

+ 144 - 0
src/pages/chat/index.less

@@ -0,0 +1,144 @@
1
+page {
2
+  background-color: #f2f2f2;
3
+  position: relative;
4
+  height: 100vh;
5
+  padding: 0 auto;
6
+  margin: 0 auto;
7
+}
8
+.mine{
9
+  height: 100vh;
10
+}
11
+.in_voice_icon {
12
+  position: absolute;
13
+  bottom: 0;
14
+  transform: translateY(0%);
15
+  width: 100%;
16
+  background-color: #F2F2F2;
17
+  min-height: 53px;
18
+  border-top: 2px solid #b5b0b0ad;
19
+}
20
+.in_voice_icon_tips{
21
+  position: absolute;
22
+  color: #F2F2F2;
23
+  top: -70px;
24
+  font-size: 28px;
25
+  padding: 10px 50px;
26
+  background-color: #948c8c94;
27
+  border-radius: 5px;
28
+  // background: url(https://we-spa.oss-cn-shenzhen.aliyuncs.com/total_picture/1677810251249.png);
29
+}
30
+
31
+.sendmessage {
32
+  margin: 20px;
33
+  z-index: 2;
34
+  display: flex;
35
+  align-items: flex-end;
36
+  flex-direction: row;
37
+}
38
+.add_icon {
39
+  width: 60px;
40
+  height: 60px;
41
+  margin: 0 auto;
42
+}
43
+
44
+.sendmessage Input {
45
+  flex: 1;
46
+  padding: 10px;
47
+  height: 60px;
48
+  border-radius: 10px;
49
+  // max-height: 150px;
50
+  background-color: #f8f8f8;
51
+  font-size: 32px;
52
+  margin-left: 20px;
53
+  padding-left: 20px;
54
+}
55
+.recognize-btn{
56
+  flex: 1;
57
+  padding: 10px;
58
+  height: 60px;
59
+  border-radius: 10px;
60
+  // max-height: 150px;
61
+  background-color: #f8f8f8;
62
+  font-size: 32px;
63
+  margin-left: 20px;
64
+  padding-left: 20px;
65
+  display: flex;
66
+  justify-content: center;
67
+  align-items: center;
68
+}
69
+
70
+.sendmessage button {
71
+  border: 1px solid white;
72
+  height: 60px;
73
+  margin-left: 20px;
74
+  background: #0c0;
75
+  color: white;
76
+  line-height: 60px;
77
+  font-size: 28px;
78
+}
79
+.scrollview{
80
+ 
81
+}
82
+.mine-speak-info{
83
+  display: flex;
84
+  padding:  20px;
85
+  justify-content: flex-end;
86
+  .mine-text{
87
+    background-color: #9EE770;
88
+    border-radius: 10px;
89
+    padding: 20px;
90
+    max-width: 485px;
91
+    position: relative;
92
+    margin-right: 20px;
93
+    .mine-text-content{
94
+
95
+    }
96
+    .mine-text-tip{
97
+      position: absolute;
98
+      right: -36px;
99
+      top: 20px;
100
+      width: 0;
101
+      height: 0;
102
+      border-top: 20px solid transparent;
103
+      border-left: 20px solid #9EE770;
104
+      border-right: 20px solid transparent;
105
+      border-bottom: 20px solid transparent;
106
+    }
107
+  }
108
+  .mine-image{
109
+    width: 80px;
110
+    height: 80px;
111
+    border-radius: 10px;
112
+  }
113
+}
114
+.other-speak-info{
115
+  display: flex;
116
+  padding:  20px;
117
+  .other-text{
118
+    background-color: #9EE770;
119
+    border-radius: 10px;
120
+    padding: 20px;
121
+    max-width: 485px;
122
+    position: relative;
123
+    margin-left: 20px;
124
+    .other-text-content{
125
+
126
+    }
127
+    .other-text-tip{
128
+      position: absolute;
129
+      left: -36px;
130
+      top: 20px;
131
+      width: 0;
132
+      height: 0;
133
+      border-top: 20px solid transparent;
134
+      border-left: 20px solid transparent;
135
+      border-right: 20px solid #9EE770;
136
+      border-bottom: 20px solid transparent;
137
+    }
138
+  }
139
+  .other-image{
140
+    width: 80px;
141
+    height: 80px;
142
+    border-radius: 10px;
143
+  }
144
+}

+ 3 - 0
src/pages/collection/index.config.js

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '首页'
3
+})

+ 24 - 0
src/pages/collection/index.jsx

@@ -0,0 +1,24 @@
1
+import { Component } from 'react'
2
+import { View, Text, Button, Image, scrollView, Input } from '@tarojs/components'
3
+import './index.less'
4
+
5
+export default class collection extends Component {
6
+
7
+  componentWillMount() { }
8
+
9
+  componentDidMount() { }
10
+
11
+  componentWillUnmount() { }
12
+
13
+  componentDidShow() { }
14
+
15
+  componentDidHide() { }
16
+
17
+  render() {
18
+    return (
19
+     <View>
20
+      collection
21
+     </View>
22
+    )
23
+  }
24
+}

+ 379 - 0
src/pages/collection/index.less

@@ -0,0 +1,379 @@
1
+page {
2
+  background-color: #f2f2f2;
3
+  height: 100%;
4
+  padding: 0 auto;
5
+  margin: 0 auto;
6
+}
7
+.login{
8
+  z-index: 999;
9
+  position: fixed;
10
+  top: 300rpx;
11
+  height: 100rpx;
12
+  text-align: center;
13
+  line-height: 100rpx;
14
+  width: 400rpx;
15
+  left: 50%;
16
+  margin-left: -200rpx;
17
+  background: white;
18
+}
19
+.Phone{
20
+  top: 500rpx;
21
+  width: 400rpx;
22
+}
23
+.login_zz{
24
+  position: fixed;
25
+  left: 0;
26
+  top: 0;
27
+  width: 100%;
28
+  height: 100%;
29
+  z-index: 998;
30
+  
31
+background-color: rgba(0,0,0,0.5);
32
+}
33
+swiper {
34
+  height: 180rpx;
35
+}
36
+ 
37
+swiper swiper-item .slide-image {
38
+  width: 100%;
39
+  height: 180rpx;
40
+}
41
+ 
42
+.jia_img {
43
+  height: 80rpx;
44
+  width: 90rpx;
45
+}
46
+ 
47
+.time {
48
+  text-align: center;
49
+  padding: 5rpx 20rpx 5rpx 20rpx;
50
+  border-radius: 10rpx;
51
+  display: block;
52
+  height: 38rpx;
53
+  line-height: 38rpx;
54
+  position: relative;
55
+  margin: 0 auto;
56
+  margin-bottom: 20rpx;
57
+  width: 90rpx;
58
+  color: white;
59
+  font-size: 26rpx;
60
+  background-color: #dedede;
61
+}
62
+ 
63
+.tab {
64
+  bottom: 120rpx;
65
+}
66
+ 
67
+.tab_1 {
68
+  position: fixed;
69
+  bottom: 50rpx;
70
+  width: 200rpx;
71
+  font-size: 26rpx;
72
+  left: 50%;
73
+  margin-left: -45rpx;
74
+  height: 100rpx;
75
+}
76
+ 
77
+.tab_2 {
78
+  right: 30rpx;
79
+  position: fixed;
80
+}
81
+ 
82
+/* 聊天 */
83
+ 
84
+.my_right {
85
+  float: right;
86
+  margin-top: 30rpx;
87
+  position: relative;
88
+}
89
+ 
90
+.my_audio {
91
+  height: 60rpx;
92
+  width: 60rpx;
93
+  z-index: 2;
94
+  position: relative;
95
+  top: 10rpx;
96
+  left: 20rpx;
97
+}
98
+ 
99
+.you_left {
100
+  margin-top: 30rpx;
101
+  float: left;
102
+  position: relative;
103
+  padding-left: 5rpx;
104
+}
105
+ 
106
+.new_img {
107
+  width: 85rpx;
108
+  height: 85rpx;
109
+  overflow: hidden;
110
+}
111
+ 
112
+.page_r {
113
+  float: right;
114
+}
115
+ 
116
+.new_txt {
117
+  min-width: 380rpx;
118
+  width: 460rpx;
119
+  word-break: break-all;
120
+}
121
+ 
122
+.new_txt_my {
123
+  border-radius: 7rpx;
124
+  background: #9fe75a;
125
+  position: relative;
126
+  right: 30rpx;
127
+  padding: 17rpx 30rpx 17rpx 30rpx;
128
+  float: right;
129
+  border: 1px solid #d0d0d0;
130
+}
131
+ 
132
+.new_txt_my .arrow {
133
+  position: absolute;
134
+  z-index: 2;
135
+  width: 40rpx;
136
+  right: -38rpx;
137
+}
138
+ 
139
+.new_txt_my .arrow em {
140
+  position: absolute;
141
+  border-style: solid;
142
+  border-width: 15rpx;
143
+  border-color: transparent transparent transparent #d0d0d0;
144
+  top: 1rpx;
145
+}
146
+ 
147
+.new_txt_my .arrow span {
148
+  position: absolute;
149
+  top: 5rpx;
150
+  border-style: solid;
151
+  border-width: 15rpx;
152
+  border-color: transparent transparent transparent #9fe75a;
153
+}
154
+ 
155
+.new_txt_my_2 {
156
+  word-break: break-all;
157
+  border-radius: 7rpx;
158
+  background: #9fe75a;
159
+  min-width: 330rpx;
160
+  max-width: 530rpx;
161
+  padding: 17rpx 30rpx 17rpx 30rpx;
162
+  float: right;
163
+}
164
+ 
165
+.new_txt_ai {
166
+  border-radius: 7rpx;
167
+  left: 20rpx;
168
+  background-color: #fff;
169
+  position: relative;
170
+  border: 1px solid #d0d0d0;
171
+  float: left;
172
+}
173
+ 
174
+.new_txt_ai .arrow {
175
+  position: relative;
176
+  width: 40rpx;
177
+  left: -30rpx;
178
+}
179
+ 
180
+.new_txt_ai .arrow em {
181
+  position: absolute;
182
+  border-style: solid;
183
+  border-width: 15rpx;
184
+  top: 20rpx;
185
+  border-color: transparent #d0d0d0 transparent transparent;
186
+}
187
+ 
188
+.new_txt_ai .arrow span {
189
+  position: absolute;
190
+  top: 20rpx;
191
+  border-style: solid;
192
+  border-width: 15rpx;
193
+  border-color: transparent #fff transparent transparent;
194
+  left: 2rpx;
195
+}
196
+ 
197
+.ai_content {
198
+  word-break: break-all;
199
+  padding: 17rpx 30rpx 17rpx 30rpx;
200
+}
201
+ 
202
+.sanjiao {
203
+  top: 25rpx;
204
+  position: relative;
205
+  width: 0px;
206
+  height: 0px;
207
+  border-width: 15rpx;
208
+  border-style: solid;
209
+}
210
+ 
211
+.my {
212
+  border-color: transparent transparent transparent #9fe75a;
213
+}
214
+ 
215
+.you {
216
+  border-color: transparent #fff transparent transparent;
217
+}
218
+ 
219
+._span {
220
+  border-color: #fff transparent transparent;
221
+  top: -17px;
222
+}
223
+ 
224
+.is_ai_btn {
225
+  border-radius: 0 0 7px 7px;
226
+  border-top: 1px solid #d0d0d0;
227
+  background: white;
228
+  position: relative;
229
+  bottom: 0;
230
+  left: 0;
231
+  width: 100%;
232
+  height: 80rpx;
233
+  line-height: 80rpx;
234
+  display: flex;
235
+  flex-direction: row;
236
+  text-align: center;
237
+}
238
+ 
239
+.is_ai_btn view {
240
+  width: 50%;
241
+}
242
+ 
243
+.is_ai_btn image {
244
+  width: 32rpx;
245
+  position: relative;
246
+  top: 4rpx;
247
+  height: 32rpx;
248
+}
249
+ 
250
+.is_ai_btn .two {
251
+  border-left: 1px solid #d0d0d0;
252
+}
253
+ 
254
+.yes_problem_log {
255
+  border-top: 1px solid #d0d0d0;
256
+  height: 80rpx;
257
+  text-align: center;
258
+  line-height: 80rpx;
259
+}
260
+ 
261
+.voice_icon {
262
+  width: 60rpx;
263
+  height: 60rpx;
264
+  margin: 0 auto;
265
+  padding: 10rpx 10rpx 10rpx 10rpx;
266
+}
267
+ 
268
+.add_icon {
269
+  width: 70rpx;
270
+  height: 70rpx;
271
+  margin: 0 auto;
272
+  padding: 20rpx 10rpx 10rpx 15rpx;
273
+}
274
+ 
275
+.voice_ing {
276
+  width: 90%;
277
+  height: 75rpx;
278
+  line-height: 85rpx;
279
+  text-align: center;
280
+  border-radius: 15rpx;
281
+  border: 1px solid #d0d0d0;
282
+}
283
+ 
284
+.zezhao {
285
+  height: 100%;
286
+  position: absolute;
287
+  top: 0;
288
+  left: 0;
289
+  z-index: 2;
290
+  width: 100%;
291
+  background: rgba(0, 0, 0, 0.5);
292
+}
293
+ 
294
+.in_voice_icon {
295
+  z-index: 3;
296
+  left: 0;
297
+  bottom: 0;
298
+  width: 100%;
299
+  position: absolute;
300
+  height: 500rpx;
301
+  background: #f8f8f8;
302
+}
303
+ 
304
+.in_voice_icon .item {
305
+  position: relative;
306
+  margin-top: 50rpx;
307
+  margin-left: 50rpx;
308
+  text-align: center;
309
+  width: 140rpx;
310
+}
311
+ 
312
+.in_voice_icon .img {
313
+  width: 80rpx;
314
+  height: 80rpx;
315
+  border-radius: 15rpx;
316
+}
317
+ 
318
+.in_voice_icon .text {
319
+  font-size: 32rpx;
320
+  margin-top: 20rpx;
321
+}
322
+ 
323
+.sendmessage {
324
+  width: 100%;
325
+  z-index: 2;
326
+  display: flex;
327
+  position: fixed;
328
+  bottom: 0px;
329
+  background-color: #f8f8f8;
330
+  flex-direction: row;
331
+  height: 100rpx;
332
+}
333
+ 
334
+.sendmessage input {
335
+  width: 78%;
336
+  height: 80rpx;
337
+  line-height: 80rpx;
338
+  font-size: 28rpx;
339
+  margin-top: 10rpx;
340
+  margin-left: 20rpx;
341
+  border-bottom: 1px solid #d0d0d0;
342
+  padding-left: 20rpx;
343
+}
344
+ 
345
+.sendmessage button {
346
+  border: 1px solid white;
347
+  width: 18%;
348
+  height: 80rpx;
349
+  background: #0c0;
350
+  color: white;
351
+  line-height: 80rpx;
352
+  margin-top: 10rpx;
353
+  font-size: 28rpx;
354
+}
355
+ 
356
+.hei {
357
+  height: 20rpx;
358
+}
359
+ 
360
+.history {
361
+  height: 88%;
362
+  display: flex;
363
+  font-size: 14px;
364
+  line-height: 50rpx;
365
+  position: relative;
366
+  top: 20rpx;
367
+}
368
+ 
369
+.icno_kf {
370
+  position: fixed;
371
+  bottom: 160rpx;
372
+  margin: 0 auto;
373
+  text-align: center;
374
+  left: 50%;
375
+  margin-left: -40rpx;
376
+  width: 100rpx;
377
+  height: 100rpx;
378
+  border-radius: 50%;
379
+}

+ 3 - 0
src/pages/mine/index.config.js

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '首页'
3
+})

+ 24 - 0
src/pages/mine/index.jsx

@@ -0,0 +1,24 @@
1
+import { Component } from 'react'
2
+import { View, Text, Button, Image, scrollView, Input } from '@tarojs/components'
3
+import './index.less'
4
+
5
+export default class Mine extends Component {
6
+
7
+  componentWillMount() { }
8
+
9
+  componentDidMount() { }
10
+
11
+  componentWillUnmount() { }
12
+
13
+  componentDidShow() { }
14
+
15
+  componentDidHide() { }
16
+
17
+  render() {
18
+    return (
19
+     <View>
20
+      mine
21
+     </View>
22
+    )
23
+  }
24
+}

+ 379 - 0
src/pages/mine/index.less

@@ -0,0 +1,379 @@
1
+page {
2
+  background-color: #f2f2f2;
3
+  height: 100%;
4
+  padding: 0 auto;
5
+  margin: 0 auto;
6
+}
7
+.login{
8
+  z-index: 999;
9
+  position: fixed;
10
+  top: 300rpx;
11
+  height: 100rpx;
12
+  text-align: center;
13
+  line-height: 100rpx;
14
+  width: 400rpx;
15
+  left: 50%;
16
+  margin-left: -200rpx;
17
+  background: white;
18
+}
19
+.Phone{
20
+  top: 500rpx;
21
+  width: 400rpx;
22
+}
23
+.login_zz{
24
+  position: fixed;
25
+  left: 0;
26
+  top: 0;
27
+  width: 100%;
28
+  height: 100%;
29
+  z-index: 998;
30
+  
31
+background-color: rgba(0,0,0,0.5);
32
+}
33
+swiper {
34
+  height: 180rpx;
35
+}
36
+ 
37
+swiper swiper-item .slide-image {
38
+  width: 100%;
39
+  height: 180rpx;
40
+}
41
+ 
42
+.jia_img {
43
+  height: 80rpx;
44
+  width: 90rpx;
45
+}
46
+ 
47
+.time {
48
+  text-align: center;
49
+  padding: 5rpx 20rpx 5rpx 20rpx;
50
+  border-radius: 10rpx;
51
+  display: block;
52
+  height: 38rpx;
53
+  line-height: 38rpx;
54
+  position: relative;
55
+  margin: 0 auto;
56
+  margin-bottom: 20rpx;
57
+  width: 90rpx;
58
+  color: white;
59
+  font-size: 26rpx;
60
+  background-color: #dedede;
61
+}
62
+ 
63
+.tab {
64
+  bottom: 120rpx;
65
+}
66
+ 
67
+.tab_1 {
68
+  position: fixed;
69
+  bottom: 50rpx;
70
+  width: 200rpx;
71
+  font-size: 26rpx;
72
+  left: 50%;
73
+  margin-left: -45rpx;
74
+  height: 100rpx;
75
+}
76
+ 
77
+.tab_2 {
78
+  right: 30rpx;
79
+  position: fixed;
80
+}
81
+ 
82
+/* 聊天 */
83
+ 
84
+.my_right {
85
+  float: right;
86
+  margin-top: 30rpx;
87
+  position: relative;
88
+}
89
+ 
90
+.my_audio {
91
+  height: 60rpx;
92
+  width: 60rpx;
93
+  z-index: 2;
94
+  position: relative;
95
+  top: 10rpx;
96
+  left: 20rpx;
97
+}
98
+ 
99
+.you_left {
100
+  margin-top: 30rpx;
101
+  float: left;
102
+  position: relative;
103
+  padding-left: 5rpx;
104
+}
105
+ 
106
+.new_img {
107
+  width: 85rpx;
108
+  height: 85rpx;
109
+  overflow: hidden;
110
+}
111
+ 
112
+.page_r {
113
+  float: right;
114
+}
115
+ 
116
+.new_txt {
117
+  min-width: 380rpx;
118
+  width: 460rpx;
119
+  word-break: break-all;
120
+}
121
+ 
122
+.new_txt_my {
123
+  border-radius: 7rpx;
124
+  background: #9fe75a;
125
+  position: relative;
126
+  right: 30rpx;
127
+  padding: 17rpx 30rpx 17rpx 30rpx;
128
+  float: right;
129
+  border: 1px solid #d0d0d0;
130
+}
131
+ 
132
+.new_txt_my .arrow {
133
+  position: absolute;
134
+  z-index: 2;
135
+  width: 40rpx;
136
+  right: -38rpx;
137
+}
138
+ 
139
+.new_txt_my .arrow em {
140
+  position: absolute;
141
+  border-style: solid;
142
+  border-width: 15rpx;
143
+  border-color: transparent transparent transparent #d0d0d0;
144
+  top: 1rpx;
145
+}
146
+ 
147
+.new_txt_my .arrow span {
148
+  position: absolute;
149
+  top: 5rpx;
150
+  border-style: solid;
151
+  border-width: 15rpx;
152
+  border-color: transparent transparent transparent #9fe75a;
153
+}
154
+ 
155
+.new_txt_my_2 {
156
+  word-break: break-all;
157
+  border-radius: 7rpx;
158
+  background: #9fe75a;
159
+  min-width: 330rpx;
160
+  max-width: 530rpx;
161
+  padding: 17rpx 30rpx 17rpx 30rpx;
162
+  float: right;
163
+}
164
+ 
165
+.new_txt_ai {
166
+  border-radius: 7rpx;
167
+  left: 20rpx;
168
+  background-color: #fff;
169
+  position: relative;
170
+  border: 1px solid #d0d0d0;
171
+  float: left;
172
+}
173
+ 
174
+.new_txt_ai .arrow {
175
+  position: relative;
176
+  width: 40rpx;
177
+  left: -30rpx;
178
+}
179
+ 
180
+.new_txt_ai .arrow em {
181
+  position: absolute;
182
+  border-style: solid;
183
+  border-width: 15rpx;
184
+  top: 20rpx;
185
+  border-color: transparent #d0d0d0 transparent transparent;
186
+}
187
+ 
188
+.new_txt_ai .arrow span {
189
+  position: absolute;
190
+  top: 20rpx;
191
+  border-style: solid;
192
+  border-width: 15rpx;
193
+  border-color: transparent #fff transparent transparent;
194
+  left: 2rpx;
195
+}
196
+ 
197
+.ai_content {
198
+  word-break: break-all;
199
+  padding: 17rpx 30rpx 17rpx 30rpx;
200
+}
201
+ 
202
+.sanjiao {
203
+  top: 25rpx;
204
+  position: relative;
205
+  width: 0px;
206
+  height: 0px;
207
+  border-width: 15rpx;
208
+  border-style: solid;
209
+}
210
+ 
211
+.my {
212
+  border-color: transparent transparent transparent #9fe75a;
213
+}
214
+ 
215
+.you {
216
+  border-color: transparent #fff transparent transparent;
217
+}
218
+ 
219
+._span {
220
+  border-color: #fff transparent transparent;
221
+  top: -17px;
222
+}
223
+ 
224
+.is_ai_btn {
225
+  border-radius: 0 0 7px 7px;
226
+  border-top: 1px solid #d0d0d0;
227
+  background: white;
228
+  position: relative;
229
+  bottom: 0;
230
+  left: 0;
231
+  width: 100%;
232
+  height: 80rpx;
233
+  line-height: 80rpx;
234
+  display: flex;
235
+  flex-direction: row;
236
+  text-align: center;
237
+}
238
+ 
239
+.is_ai_btn view {
240
+  width: 50%;
241
+}
242
+ 
243
+.is_ai_btn image {
244
+  width: 32rpx;
245
+  position: relative;
246
+  top: 4rpx;
247
+  height: 32rpx;
248
+}
249
+ 
250
+.is_ai_btn .two {
251
+  border-left: 1px solid #d0d0d0;
252
+}
253
+ 
254
+.yes_problem_log {
255
+  border-top: 1px solid #d0d0d0;
256
+  height: 80rpx;
257
+  text-align: center;
258
+  line-height: 80rpx;
259
+}
260
+ 
261
+.voice_icon {
262
+  width: 60rpx;
263
+  height: 60rpx;
264
+  margin: 0 auto;
265
+  padding: 10rpx 10rpx 10rpx 10rpx;
266
+}
267
+ 
268
+.add_icon {
269
+  width: 70rpx;
270
+  height: 70rpx;
271
+  margin: 0 auto;
272
+  padding: 20rpx 10rpx 10rpx 15rpx;
273
+}
274
+ 
275
+.voice_ing {
276
+  width: 90%;
277
+  height: 75rpx;
278
+  line-height: 85rpx;
279
+  text-align: center;
280
+  border-radius: 15rpx;
281
+  border: 1px solid #d0d0d0;
282
+}
283
+ 
284
+.zezhao {
285
+  height: 100%;
286
+  position: absolute;
287
+  top: 0;
288
+  left: 0;
289
+  z-index: 2;
290
+  width: 100%;
291
+  background: rgba(0, 0, 0, 0.5);
292
+}
293
+ 
294
+.in_voice_icon {
295
+  z-index: 3;
296
+  left: 0;
297
+  bottom: 0;
298
+  width: 100%;
299
+  position: absolute;
300
+  height: 500rpx;
301
+  background: #f8f8f8;
302
+}
303
+ 
304
+.in_voice_icon .item {
305
+  position: relative;
306
+  margin-top: 50rpx;
307
+  margin-left: 50rpx;
308
+  text-align: center;
309
+  width: 140rpx;
310
+}
311
+ 
312
+.in_voice_icon .img {
313
+  width: 80rpx;
314
+  height: 80rpx;
315
+  border-radius: 15rpx;
316
+}
317
+ 
318
+.in_voice_icon .text {
319
+  font-size: 32rpx;
320
+  margin-top: 20rpx;
321
+}
322
+ 
323
+.sendmessage {
324
+  width: 100%;
325
+  z-index: 2;
326
+  display: flex;
327
+  position: fixed;
328
+  bottom: 0px;
329
+  background-color: #f8f8f8;
330
+  flex-direction: row;
331
+  height: 100rpx;
332
+}
333
+ 
334
+.sendmessage input {
335
+  width: 78%;
336
+  height: 80rpx;
337
+  line-height: 80rpx;
338
+  font-size: 28rpx;
339
+  margin-top: 10rpx;
340
+  margin-left: 20rpx;
341
+  border-bottom: 1px solid #d0d0d0;
342
+  padding-left: 20rpx;
343
+}
344
+ 
345
+.sendmessage button {
346
+  border: 1px solid white;
347
+  width: 18%;
348
+  height: 80rpx;
349
+  background: #0c0;
350
+  color: white;
351
+  line-height: 80rpx;
352
+  margin-top: 10rpx;
353
+  font-size: 28rpx;
354
+}
355
+ 
356
+.hei {
357
+  height: 20rpx;
358
+}
359
+ 
360
+.history {
361
+  height: 88%;
362
+  display: flex;
363
+  font-size: 14px;
364
+  line-height: 50rpx;
365
+  position: relative;
366
+  top: 20rpx;
367
+}
368
+ 
369
+.icno_kf {
370
+  position: fixed;
371
+  bottom: 160rpx;
372
+  margin: 0 auto;
373
+  text-align: center;
374
+  left: 50%;
375
+  margin-left: -40rpx;
376
+  width: 100rpx;
377
+  height: 100rpx;
378
+  border-radius: 50%;
379
+}

+ 3 - 0
src/pages/task/index.config.js

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '首页'
3
+})

+ 24 - 0
src/pages/task/index.jsx

@@ -0,0 +1,24 @@
1
+import { Component } from 'react'
2
+import { View, Text, Button, Image, scrollView, Input } from '@tarojs/components'
3
+import './index.less'
4
+
5
+export default class Task extends Component {
6
+
7
+  componentWillMount() { }
8
+
9
+  componentDidMount() { }
10
+
11
+  componentWillUnmount() { }
12
+
13
+  componentDidShow() { }
14
+
15
+  componentDidHide() { }
16
+
17
+  render() {
18
+    return (
19
+      <View>
20
+        task
21
+      </View>
22
+    )
23
+  }
24
+}

+ 379 - 0
src/pages/task/index.less

@@ -0,0 +1,379 @@
1
+page {
2
+  background-color: #f2f2f2;
3
+  height: 100%;
4
+  padding: 0 auto;
5
+  margin: 0 auto;
6
+}
7
+.login{
8
+  z-index: 999;
9
+  position: fixed;
10
+  top: 300rpx;
11
+  height: 100rpx;
12
+  text-align: center;
13
+  line-height: 100rpx;
14
+  width: 400rpx;
15
+  left: 50%;
16
+  margin-left: -200rpx;
17
+  background: white;
18
+}
19
+.Phone{
20
+  top: 500rpx;
21
+  width: 400rpx;
22
+}
23
+.login_zz{
24
+  position: fixed;
25
+  left: 0;
26
+  top: 0;
27
+  width: 100%;
28
+  height: 100%;
29
+  z-index: 998;
30
+  
31
+background-color: rgba(0,0,0,0.5);
32
+}
33
+swiper {
34
+  height: 180rpx;
35
+}
36
+ 
37
+swiper swiper-item .slide-image {
38
+  width: 100%;
39
+  height: 180rpx;
40
+}
41
+ 
42
+.jia_img {
43
+  height: 80rpx;
44
+  width: 90rpx;
45
+}
46
+ 
47
+.time {
48
+  text-align: center;
49
+  padding: 5rpx 20rpx 5rpx 20rpx;
50
+  border-radius: 10rpx;
51
+  display: block;
52
+  height: 38rpx;
53
+  line-height: 38rpx;
54
+  position: relative;
55
+  margin: 0 auto;
56
+  margin-bottom: 20rpx;
57
+  width: 90rpx;
58
+  color: white;
59
+  font-size: 26rpx;
60
+  background-color: #dedede;
61
+}
62
+ 
63
+.tab {
64
+  bottom: 120rpx;
65
+}
66
+ 
67
+.tab_1 {
68
+  position: fixed;
69
+  bottom: 50rpx;
70
+  width: 200rpx;
71
+  font-size: 26rpx;
72
+  left: 50%;
73
+  margin-left: -45rpx;
74
+  height: 100rpx;
75
+}
76
+ 
77
+.tab_2 {
78
+  right: 30rpx;
79
+  position: fixed;
80
+}
81
+ 
82
+/* 聊天 */
83
+ 
84
+.my_right {
85
+  float: right;
86
+  margin-top: 30rpx;
87
+  position: relative;
88
+}
89
+ 
90
+.my_audio {
91
+  height: 60rpx;
92
+  width: 60rpx;
93
+  z-index: 2;
94
+  position: relative;
95
+  top: 10rpx;
96
+  left: 20rpx;
97
+}
98
+ 
99
+.you_left {
100
+  margin-top: 30rpx;
101
+  float: left;
102
+  position: relative;
103
+  padding-left: 5rpx;
104
+}
105
+ 
106
+.new_img {
107
+  width: 85rpx;
108
+  height: 85rpx;
109
+  overflow: hidden;
110
+}
111
+ 
112
+.page_r {
113
+  float: right;
114
+}
115
+ 
116
+.new_txt {
117
+  min-width: 380rpx;
118
+  width: 460rpx;
119
+  word-break: break-all;
120
+}
121
+ 
122
+.new_txt_my {
123
+  border-radius: 7rpx;
124
+  background: #9fe75a;
125
+  position: relative;
126
+  right: 30rpx;
127
+  padding: 17rpx 30rpx 17rpx 30rpx;
128
+  float: right;
129
+  border: 1px solid #d0d0d0;
130
+}
131
+ 
132
+.new_txt_my .arrow {
133
+  position: absolute;
134
+  z-index: 2;
135
+  width: 40rpx;
136
+  right: -38rpx;
137
+}
138
+ 
139
+.new_txt_my .arrow em {
140
+  position: absolute;
141
+  border-style: solid;
142
+  border-width: 15rpx;
143
+  border-color: transparent transparent transparent #d0d0d0;
144
+  top: 1rpx;
145
+}
146
+ 
147
+.new_txt_my .arrow span {
148
+  position: absolute;
149
+  top: 5rpx;
150
+  border-style: solid;
151
+  border-width: 15rpx;
152
+  border-color: transparent transparent transparent #9fe75a;
153
+}
154
+ 
155
+.new_txt_my_2 {
156
+  word-break: break-all;
157
+  border-radius: 7rpx;
158
+  background: #9fe75a;
159
+  min-width: 330rpx;
160
+  max-width: 530rpx;
161
+  padding: 17rpx 30rpx 17rpx 30rpx;
162
+  float: right;
163
+}
164
+ 
165
+.new_txt_ai {
166
+  border-radius: 7rpx;
167
+  left: 20rpx;
168
+  background-color: #fff;
169
+  position: relative;
170
+  border: 1px solid #d0d0d0;
171
+  float: left;
172
+}
173
+ 
174
+.new_txt_ai .arrow {
175
+  position: relative;
176
+  width: 40rpx;
177
+  left: -30rpx;
178
+}
179
+ 
180
+.new_txt_ai .arrow em {
181
+  position: absolute;
182
+  border-style: solid;
183
+  border-width: 15rpx;
184
+  top: 20rpx;
185
+  border-color: transparent #d0d0d0 transparent transparent;
186
+}
187
+ 
188
+.new_txt_ai .arrow span {
189
+  position: absolute;
190
+  top: 20rpx;
191
+  border-style: solid;
192
+  border-width: 15rpx;
193
+  border-color: transparent #fff transparent transparent;
194
+  left: 2rpx;
195
+}
196
+ 
197
+.ai_content {
198
+  word-break: break-all;
199
+  padding: 17rpx 30rpx 17rpx 30rpx;
200
+}
201
+ 
202
+.sanjiao {
203
+  top: 25rpx;
204
+  position: relative;
205
+  width: 0px;
206
+  height: 0px;
207
+  border-width: 15rpx;
208
+  border-style: solid;
209
+}
210
+ 
211
+.my {
212
+  border-color: transparent transparent transparent #9fe75a;
213
+}
214
+ 
215
+.you {
216
+  border-color: transparent #fff transparent transparent;
217
+}
218
+ 
219
+._span {
220
+  border-color: #fff transparent transparent;
221
+  top: -17px;
222
+}
223
+ 
224
+.is_ai_btn {
225
+  border-radius: 0 0 7px 7px;
226
+  border-top: 1px solid #d0d0d0;
227
+  background: white;
228
+  position: relative;
229
+  bottom: 0;
230
+  left: 0;
231
+  width: 100%;
232
+  height: 80rpx;
233
+  line-height: 80rpx;
234
+  display: flex;
235
+  flex-direction: row;
236
+  text-align: center;
237
+}
238
+ 
239
+.is_ai_btn view {
240
+  width: 50%;
241
+}
242
+ 
243
+.is_ai_btn image {
244
+  width: 32rpx;
245
+  position: relative;
246
+  top: 4rpx;
247
+  height: 32rpx;
248
+}
249
+ 
250
+.is_ai_btn .two {
251
+  border-left: 1px solid #d0d0d0;
252
+}
253
+ 
254
+.yes_problem_log {
255
+  border-top: 1px solid #d0d0d0;
256
+  height: 80rpx;
257
+  text-align: center;
258
+  line-height: 80rpx;
259
+}
260
+ 
261
+.voice_icon {
262
+  width: 60rpx;
263
+  height: 60rpx;
264
+  margin: 0 auto;
265
+  padding: 10rpx 10rpx 10rpx 10rpx;
266
+}
267
+ 
268
+.add_icon {
269
+  width: 70rpx;
270
+  height: 70rpx;
271
+  margin: 0 auto;
272
+  padding: 20rpx 10rpx 10rpx 15rpx;
273
+}
274
+ 
275
+.voice_ing {
276
+  width: 90%;
277
+  height: 75rpx;
278
+  line-height: 85rpx;
279
+  text-align: center;
280
+  border-radius: 15rpx;
281
+  border: 1px solid #d0d0d0;
282
+}
283
+ 
284
+.zezhao {
285
+  height: 100%;
286
+  position: absolute;
287
+  top: 0;
288
+  left: 0;
289
+  z-index: 2;
290
+  width: 100%;
291
+  background: rgba(0, 0, 0, 0.5);
292
+}
293
+ 
294
+.in_voice_icon {
295
+  z-index: 3;
296
+  left: 0;
297
+  bottom: 0;
298
+  width: 100%;
299
+  position: absolute;
300
+  height: 500rpx;
301
+  background: #f8f8f8;
302
+}
303
+ 
304
+.in_voice_icon .item {
305
+  position: relative;
306
+  margin-top: 50rpx;
307
+  margin-left: 50rpx;
308
+  text-align: center;
309
+  width: 140rpx;
310
+}
311
+ 
312
+.in_voice_icon .img {
313
+  width: 80rpx;
314
+  height: 80rpx;
315
+  border-radius: 15rpx;
316
+}
317
+ 
318
+.in_voice_icon .text {
319
+  font-size: 32rpx;
320
+  margin-top: 20rpx;
321
+}
322
+ 
323
+.sendmessage {
324
+  width: 100%;
325
+  z-index: 2;
326
+  display: flex;
327
+  position: fixed;
328
+  bottom: 0px;
329
+  background-color: #f8f8f8;
330
+  flex-direction: row;
331
+  height: 100rpx;
332
+}
333
+ 
334
+.sendmessage input {
335
+  width: 78%;
336
+  height: 80rpx;
337
+  line-height: 80rpx;
338
+  font-size: 28rpx;
339
+  margin-top: 10rpx;
340
+  margin-left: 20rpx;
341
+  border-bottom: 1px solid #d0d0d0;
342
+  padding-left: 20rpx;
343
+}
344
+ 
345
+.sendmessage button {
346
+  border: 1px solid white;
347
+  width: 18%;
348
+  height: 80rpx;
349
+  background: #0c0;
350
+  color: white;
351
+  line-height: 80rpx;
352
+  margin-top: 10rpx;
353
+  font-size: 28rpx;
354
+}
355
+ 
356
+.hei {
357
+  height: 20rpx;
358
+}
359
+ 
360
+.history {
361
+  height: 88%;
362
+  display: flex;
363
+  font-size: 14px;
364
+  line-height: 50rpx;
365
+  position: relative;
366
+  top: 20rpx;
367
+}
368
+ 
369
+.icno_kf {
370
+  position: fixed;
371
+  bottom: 160rpx;
372
+  margin: 0 auto;
373
+  text-align: center;
374
+  left: 50%;
375
+  margin-left: -40rpx;
376
+  width: 100rpx;
377
+  height: 100rpx;
378
+  border-radius: 50%;
379
+}

+ 13 - 0
src/service/index.js

@@ -0,0 +1,13 @@
1
+//首页js接口
2
+import Request from '../api/request';
3
+
4
+
5
+
6
+//获取机器人的回答
7
+export const getAsk = data =>
8
+  Request({
9
+    url: '/api/ask',
10
+    method: 'POST',
11
+    data,
12
+  });
13
+

+ 19 - 0
types/global.d.ts

@@ -0,0 +1,19 @@
1
+/// <reference types="@tarojs/taro" />
2
+
3
+declare module '*.png';
4
+declare module '*.gif';
5
+declare module '*.jpg';
6
+declare module '*.jpeg';
7
+declare module '*.svg';
8
+declare module '*.css';
9
+declare module '*.less';
10
+declare module '*.scss';
11
+declare module '*.sass';
12
+declare module '*.styl';
13
+
14
+declare namespace NodeJS {
15
+  interface ProcessEnv {
16
+    TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
17
+  }
18
+}
19
+