index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="content">
  3. <navigation-custom :config="config" :scrollTop="scrollTop" @customConduct="customConduct" :scrollMaxHeight="scrollMaxHeight"/>
  4. <view class='chat-box' :style="{ 'min-height': nowHeight}">
  5. <view class="tips-box">
  6. {{nowTime}}
  7. </view>
  8. <view class="tips-box tips-title" >
  9. 您好,智能投顾很高兴为您服务!
  10. </view>
  11. <view class="talk-box" >
  12. <view class="talk-head-box">
  13. <image src="../../static/logo.png" mode="" class="talk-head"></image>
  14. </view>
  15. <view class="talk-content">您好,智能顾投很高兴为您服务!</view>
  16. </view>
  17. <view v-for="chat in talkList" :key="chat.talkType">
  18. <view class="talk-box talk-box-end" v-show="chat.content">
  19. <view class="talk-content">{{chat.content}}</view>
  20. <view class="talk-head-box">
  21. <image :src='userHeadUrl' mode="" class="talk-head"></image>
  22. </view>
  23. </view>
  24. <view class="talk-box">
  25. <view class="talk-head-box">
  26. <image :src='rabotHeadImg' mode="" class="talk-head"></image>
  27. </view>
  28. <view class="talk-content">{{chat.reply}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="send-box">
  33. <input type="number" class="enter-box" v-model="inputInfo">
  34. <button type="primary" class="submit-message" @click="sendInputInfo()">发送</button>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import navigationCustom from "../../components/struggler-navigationCustom/navigation-custom";
  40. var md5 = require("../../common/md5.js");
  41. export default {
  42. data() {
  43. return {
  44. title: 'RABOT',
  45. nowTime:'',
  46. nowHeight:'622px',
  47. inputInfo:'',
  48. rabotHeadImg:"../../static/logo.png",
  49. userHeadUrl:getApp().globalData.user_headUrl || '../../static/alienware.png',
  50. talkList:[
  51. {
  52. "id": "1",
  53. "content": "",
  54. "reply": "欢迎您使用阿拉灯神丁,您有10次免费查询机会,输入股票代码(例如:000001)试试吧!",
  55. "uid": "1",
  56. "type": "0",
  57. "addtime": "1575961303",
  58. },
  59. {
  60. "id": "2",
  61. "reply": "参与投股100人,62人建议买入,30人建议卖出,8人建议持有不操作",
  62. "uid": "1",
  63. "type": "0",
  64. "addtime": "1575961303",
  65. headUrl:'../../static/logo.png',
  66. content:'000001',
  67. },
  68. {
  69. "id": "3",
  70. "reply": "停市啦!",
  71. "uid": "1",
  72. "type": "0",
  73. "addtime": "1575961303",
  74. headUrl:'../../static/logo.png',
  75. content:'000003',
  76. },
  77. {
  78. "id": "3",
  79. "reply": "停市啦!",
  80. "uid": "1",
  81. "type": "0",
  82. "addtime": "1575961303",
  83. headUrl:'../../static/logo.png',
  84. content:'000003',
  85. },
  86. {
  87. "id": "3",
  88. "reply": "停市啦!",
  89. "uid": "1",
  90. "type": "0",
  91. "addtime": "1575961303",
  92. headUrl:'../../static/logo.png',
  93. content:'000003',
  94. },{
  95. "id": "3",
  96. "reply": "停市啦!",
  97. "uid": "1",
  98. "type": "0",
  99. "addtime": "1575961303",
  100. headUrl:'../../static/logo.png',
  101. content:'000003',
  102. },
  103. ],
  104. config:{
  105. title:"阿拉丁神灯", //title
  106. bgcolor:"#fff", //背景颜色
  107. fontcolor:"black", //文字颜色,默认白色
  108. type:3, //type 1,3胶囊 2,4无胶囊模式
  109. transparent:false, //是否背景透明 默认白色
  110. linear:true, //是为开启下滑渐变
  111. share:true, //是否将主页按钮显示为分享按钮
  112. menuIcon:"../../static/icon/iconfont-user.png", //当type为3或者4的时候左边的icon文件位置,注意位置与当前页面不一样
  113. // menuText:"返回", 当type为3或4的时候icon右边的文字
  114. },
  115. scrollTop:0 ,// 当linear为true的时候需要通过onpagescroll传递参数
  116. scrollMaxHeight:200 //滑动的高度限制,超过这个高度即背景全部显示
  117. }
  118. },
  119. components:{
  120. navigationCustom
  121. },
  122. onPageScroll(e) {
  123. this.scrollTop = e.scrollTop;
  124. },
  125. onLoad() {
  126. this.getEquipmentHeight();
  127. this.getHistory();
  128. },
  129. onShow() {
  130. this.getNowTime();
  131. },
  132. methods: {
  133. getNowTime(){
  134. let time = new Date();
  135. let y=time.getFullYear();
  136. let m=time.getMonth()+1;
  137. let d=time.getDate();
  138. let h=time.getHours();
  139. let i=time.getMinutes();
  140. i = i > 10 ? i : '0' + i;
  141. this.nowTime = y+"年"+m+"月"+d+"日"+" "+h+":"+i
  142. },
  143. getEquipmentHeight() {
  144. let height = uni.getSystemInfoSync().windowHeight;
  145. this.nowHeight = height + 'px';
  146. getApp().globalData.glbalHeight = this.nowHeight;
  147. },
  148. getHistory(){
  149. let that = this;
  150. uni.request({
  151. url:getApp().globalData.shareUrl, //需要设置为全局
  152. method: 'POST',
  153. header: {
  154. 'content-type': 'application/x-www-form-urlencoded'
  155. },
  156. data: {
  157. method: 'question_list',
  158. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  159. uid:getApp().globalData.user_id,
  160. sign: md5('question_list' + getApp().globalData.globalTimestamp),
  161. page:1,
  162. pageSize:10,
  163. },
  164. success: res => {
  165. that.talkList = (res.data.msg).reverse();
  166. that.userHeadUrl = getApp().globalData.user_headUrl
  167. }
  168. });
  169. },
  170. customConduct(){
  171. uni.navigateTo({
  172. url:'../selfInfo/selfInfo'
  173. })
  174. },
  175. sendInputInfo(){
  176. if(!this.inputInfo){
  177. uni.showToast({
  178. title: '请输入股票代码',
  179. icon: 'none'
  180. });
  181. }else {
  182. let obj = {
  183. talkType:1 ,// 代表用户
  184. headUrl:'../../static/alienware.png',
  185. content:this.inputInfo,
  186. }
  187. this.talkList.push(obj);
  188. this.inputInfo = '';
  189. }
  190. }
  191. },
  192. }
  193. </script>
  194. <style>
  195. .content {
  196. text-align: center;
  197. }
  198. .chat-box {
  199. background: #f4f5f7;
  200. padding-top: 3%;
  201. padding-bottom:100upx;
  202. }
  203. .tips-box {
  204. background:#D5D5DA;
  205. font-size: 28upx;
  206. color: #fff;
  207. border-radius: 30upx;
  208. width: 50%;
  209. margin: 0 auto;
  210. height: 50rpx;
  211. line-height: 50rpx
  212. }
  213. .tips-title{
  214. width: 70%;
  215. margin-top: 5%;
  216. font-size: 30rpx;
  217. height: 70rpx;
  218. line-height: 70rpx
  219. }
  220. .send-box {
  221. width: 100%;
  222. height: 90rpx;
  223. position: fixed;
  224. bottom: 0;
  225. background: #F4F0ED;
  226. display: flex;
  227. align-items: center;
  228. }
  229. .talk-box {
  230. display: flex;
  231. justify-content: flex-start;
  232. align-items: center;
  233. margin-top: 3%;
  234. }
  235. .talk-box-end{
  236. justify-content: flex-end;
  237. }
  238. .talk-head-box {
  239. width: 80rpx;
  240. height:80rpx;
  241. border-radius: 30rpx;
  242. margin-left: 2%;
  243. margin-right: 2%;
  244. }
  245. .talk-head {
  246. width: 100%;
  247. height: 100%;
  248. border-radius: 50%;
  249. }
  250. .talk-content {
  251. padding: 2%;
  252. background: #fff;
  253. /* height:50rpx;
  254. line-height: 50rpx; */
  255. font-size: 28rpx;
  256. border-top-right-radius: 20rpx;
  257. border-bottom-left-radius: 20rpx;
  258. border-bottom-right-radius:20rpx;
  259. text-align: left;
  260. max-width: 70%;
  261. }
  262. .enter-box {
  263. width: 78%;
  264. height: 70rpx;
  265. margin-left: 5px;
  266. background: #fff;
  267. border-radius: 1%;
  268. text-align: left;
  269. }
  270. .submit-message {
  271. width: 18%;
  272. height: 70rpx;
  273. font-size: 28rpx;
  274. line-height: 70rpx;
  275. color: #fff;
  276. background-color: #0A98D5!important;
  277. }
  278. .logo {
  279. height: 200upx;
  280. width: 200upx;
  281. margin-top: 200upx;
  282. margin-left: auto;
  283. margin-right: auto;
  284. margin-bottom: 50upx;
  285. }
  286. .text-area {
  287. display: flex;
  288. justify-content: center;
  289. }
  290. .title {
  291. font-size: 36upx;
  292. color: #8f8f94;
  293. }
  294. </style>