home.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <div class="top" :style="{'background-image':'url('+require('../static/top_bg.png')+')','margin-top':-mt+'px'}">
  4. <div class="t_box" :style="{'background-image':'url('+require('../static/top_boxbg.png')+')'}">
  5. <image src="@/static/ai_shape.png"></image>
  6. <div class="text adffcac">
  7. <text>Hi!我是甜心小兔</text>
  8. <p>
  9. 支持语音唤醒 按键对话<br>
  10. 回应每一个奇思妙想<br>
  11. 好奇的孩子更聪明~
  12. </p>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="card">
  17. <div class="title adfacjb">
  18. <div class="t_l">我的设备</div>
  19. </div>
  20. <div class="device_boxs adfacjb">
  21. <div class="db_pre adffcjb" :style="{'background-image':'url('+require('../static/box_bg2.png')+')'}" @tap="addBindDevice">
  22. <div class="dp_top adfac">
  23. <image src="@/static/bind.png"></image>
  24. <span>绑定设备</span>
  25. </div>
  26. <div class="dp_tip">按照产品教程绑定设备,添加成功后选择角色</div>
  27. </div>
  28. <div class="db_pre adffcjb" :style="{'background-image':'url('+require('../static/box_bg1.png')+')'}" @tap="toTurn('/pages/wifi')">
  29. <div class="dp_top adfac">
  30. <image src="@/static/change.png"></image>
  31. <span>网络连接</span>
  32. </div>
  33. <div class="dp_tip">请先连接热点,然后选择要连接的网络</div>
  34. </div>
  35. </div>
  36. <template v-if="agentList.length">
  37. <div class="title adfacjb" style="margin-top: 70rpx;margin-bottom: 22rpx;">
  38. <div class="t_l">我的角色</div>
  39. <div class="t_r">查看全部</div>
  40. </div>
  41. <div class="a_item adfacjb" v-for="(item,index) in agentList" :key="index">
  42. <div class="ai_l">
  43. {{item.agentName}}
  44. </div>
  45. <div class="ai_r" @tap="toAgentDetail(item)">查看</div>
  46. </div>
  47. </template>
  48. </div>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data(){
  54. return {
  55. deviceList:[],
  56. agentList:[]
  57. }
  58. },
  59. onLoad() {
  60. this.getAgentList();
  61. },
  62. methods:{
  63. getAgentList(){
  64. this.$api.get('/agent/list').then(res=>{
  65. if(res.data.code!==0) return this.$showToast(res.data.msg)
  66. this.agentList = res.data.data.splice(0,5);
  67. })
  68. },
  69. addBindDevice(){
  70. uni.scanCode({
  71. success: (res) => {
  72. let result = JSON.parse(res.result);
  73. if(res.errMsg==='scanCode:ok'){
  74. this.$api.post('/device/bindAdd',{
  75. ...result,
  76. "type": "",
  77. "userId": 0,
  78. "agentId": ""
  79. }).then(res=>{
  80. if(res.data.code!==0) return this.$showToast(res.data.msg)
  81. uni.navigateTo({
  82. url:'/pages/agentCreate'
  83. })
  84. })
  85. }
  86. }
  87. })
  88. },
  89. toTurn(url){
  90. uni.navigateTo({ url })
  91. },
  92. toAgentDetail(item){
  93. uni.navigateTo({
  94. url:'/pages/agentDetail?id='+item.id+'&vname='+item.ttsVoiceName
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped lang="less">
  101. .page{
  102. background: linear-gradient( 180deg, #E0EEFF 0%, #F6FCFF 100%);
  103. box-sizing: border-box;
  104. .top{
  105. width: 100%;
  106. height: 564rpx;
  107. background-repeat: no-repeat;
  108. background-size: 100% 100%;
  109. position: relative;
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: flex-end;
  113. .t_box{
  114. width: calc(100% - 60rpx);
  115. height: 296rpx;
  116. background-repeat: no-repeat;
  117. background-size: 100% 100%;
  118. position: relative;
  119. bottom: 30rpx;
  120. left: 30rpx;
  121. image{
  122. width: 256rpx;
  123. height: 336rpx;
  124. position: absolute;
  125. left: 38rpx;
  126. bottom: 14rpx;
  127. }
  128. .text{
  129. padding: 66rpx 46rpx 0 332rpx;
  130. text{
  131. font-family: PingFangSC, PingFang SC;
  132. font-weight: 500;
  133. font-size: 40rpx;
  134. color: #FFFFFF;
  135. line-height: 56rpx;
  136. }
  137. p{
  138. font-family: PingFangSC, PingFang SC;
  139. font-weight: 400;
  140. font-size: 26rpx;
  141. color: #FFFFFF;
  142. line-height: 48rpx;
  143. margin-top: 12rpx;
  144. }
  145. }
  146. }
  147. }
  148. .card{
  149. padding: 0 30rpx 30rpx;
  150. .title{
  151. margin-top: 36rpx;
  152. .t_l{
  153. font-family: PingFangSC, PingFang SC;
  154. font-weight: 600;
  155. font-size: 36rpx;
  156. color: #111111;
  157. line-height: 50rpx;
  158. text-align: left;
  159. }
  160. .t_r{
  161. font-family: PingFangSC, PingFang SC;
  162. font-weight: 400;
  163. font-size: 28rpx;
  164. color: #0066FE;
  165. line-height: 40rpx;
  166. text-align: right;
  167. }
  168. }
  169. .device_empty{
  170. background: #FFFFFF;
  171. box-shadow: 0rpx 4rpx 20rpx 0rpx #E5EDFF;
  172. border-radius: 24rpx;
  173. margin-top: 32rpx;
  174. padding: 48rpx 79rpx;
  175. background: #FFFFFF;
  176. p{
  177. font-family: PingFangSC, PingFang SC;
  178. font-weight: 400;
  179. font-size: 28rpx;
  180. color: #5C5C5C;
  181. line-height: 48rpx;
  182. text-align: center;
  183. }
  184. .de_btn{
  185. width: 320rpx;
  186. height: 72rpx;
  187. background: #0066FE;
  188. border-radius: 16rpx;
  189. margin-top: 40rpx;
  190. image{
  191. width: 30rpx;
  192. height: 30rpx;
  193. }
  194. span{
  195. font-family: PingFang-SC, PingFang-SC;
  196. font-weight: bold;
  197. font-size: 28rpx;
  198. color: #FFFFFF;
  199. line-height: 32rpx;
  200. margin-left: 16rpx;
  201. }
  202. }
  203. }
  204. .device_boxs{
  205. margin-top: 31rpx;
  206. .db_pre{
  207. width: calc(50% - 15rpx);
  208. height: 138px;
  209. padding: 36rpx 30rpx;
  210. box-sizing: border-box;
  211. background-repeat: no-repeat;
  212. background-size: 100% 100%;
  213. .dp_top{
  214. image{
  215. width: 40rpx;
  216. height: 40rpx;
  217. }
  218. span{
  219. font-family: PingFang-SC, PingFang-SC;
  220. font-weight: bold;
  221. font-size: 32rpx;
  222. color: #333333;
  223. line-height: 32rpx;
  224. text-align: left;
  225. margin-left: 40rpx;
  226. }
  227. }
  228. .dp_tip{
  229. font-family: PingFangSC, PingFang SC;
  230. font-weight: 400;
  231. font-size: 24rpx;
  232. color: #6E696F;
  233. line-height: 40rpx;
  234. }
  235. }
  236. }
  237. .a_item{
  238. width: 100%;
  239. padding: 37rpx 20rpx;
  240. box-sizing: border-box;
  241. background: #FFFFFF;
  242. margin-top: 30rpx;
  243. .ai_l{
  244. width: calc(100% - 114rpx);
  245. font-family: PingFang-SC, PingFang-SC;
  246. font-weight: bold;
  247. font-size: 32rpx;
  248. color: #111111;
  249. line-height: 32rpx;
  250. overflow: hidden;
  251. white-space: nowrap;
  252. text-overflow: ellipsis;
  253. }
  254. .ai_r{
  255. width: 94rpx;
  256. height: 56rpx;
  257. background: #0066FE;
  258. border-radius: 16rpx;
  259. font-family: PingFang-SC, PingFang-SC;
  260. font-weight: bold;
  261. font-size: 24rpx;
  262. color: #FFFFFF;
  263. line-height: 56rpx;
  264. text-align: center;
  265. }
  266. }
  267. }
  268. }
  269. </style>