index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <layoutBack :isGoBack='true'>
  3. <layout title='推荐云手机'>
  4. <div :class="isShowApp?'introduction':'introduction introduction-white'">
  5. <div class="introduction-title" v-if="isShowApp">
  6. 推荐云手机
  7. </div>
  8. <div class="introduction-tips">
  9. 请搜索您在云手机内希望使用的应用!
  10. </div>
  11. <div class="introduction-search">
  12. <img src="@/assets/image/introductionCloudPhone/search.png" alt="" />
  13. <input ref="inputField" v-model="searchText" type="search" placeholder="请输入应用名" />
  14. <div style="width: 1px;height: 20px;background: #7E8495;border-radius: 1px;"></div>
  15. <div @click="search">搜索</div>
  16. </div>
  17. <div v-if="applicationList.length && isShow">
  18. <div class="introduction-tips" style="margin-top: 24px;">
  19. 以下推荐应用选您需要使用的应用
  20. </div>
  21. <div>
  22. <div class="application">
  23. <div v-for="(item,index) in applicationList" :key="index" @click="selectApplication(item)">
  24. {{ item }}
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div style="margin-top: 24px;" v-if="appSeatchList.length && !isShow">
  30. <div class="application-list" v-for="(item,index) in appSeatchList" :key="index">
  31. <div class="application-list-top">
  32. <img class="application-list-img" width="42" height="42" :src="item.img" alt="" />
  33. <div class="application-list-rigth">
  34. <div class="application-list-title">
  35. <div class="application-list-appname"> {{item.appName}}</div>
  36. <span v-if="item.articleId>0" @click="goArticleDetails(item)">点击阅读</span>
  37. </div>
  38. <div class="application-list-tips">{{item.appName}}云手机使用教程</div>
  39. </div>
  40. <div class="application-list-btn" @click="pay(item)">购买云手机
  41. <!-- <img width="12" src="@/assets/image/introductionCloudPhone/btn.png" /> -->
  42. </div>
  43. </div>
  44. <div class="application-list-bottom">推荐机型:{{item.list?item.list.map(o=>o.phoneTypeStr).join('/'):''}}</div>
  45. </div>
  46. </div>
  47. <div class="application-default" v-if="!appSeatchList.length && !isShow">
  48. <img v-if="isShowApp" width="305" src="@/assets/image/introductionCloudPhone/default.png" />
  49. <img v-else width="305" src="@/assets/image/introductionCloudPhone/defaultWhite.png" />
  50. <div>很遗憾,没有搜索到您想要的应用</div>
  51. </div>
  52. </div>
  53. </layout>
  54. </layoutBack>
  55. </template>
  56. <script>
  57. import layoutBack from '@/components/layout';
  58. import layout from './components/layout';
  59. import { fileKeyToUrl } from '@/plugins/file-center.js';
  60. import uni from '@/static/static/js/uni.webview.1.5.2';
  61. export default {
  62. auth: false,
  63. name: 'introductionCloudPhone',
  64. head: {
  65. title: '推荐云手机',
  66. },
  67. data() {
  68. return {
  69. searchText: '',
  70. isShow: true,
  71. applicationList: [], // 推荐应用数组
  72. appSeatchList: [], // 应用数组
  73. };
  74. },
  75. components: { layout, layoutBack },
  76. created() {
  77. this.getSuggestApp()
  78. let _this = this
  79. document.addEventListener('keydown', function (e) {
  80. // 检查是否是搜索键(通常是“Enter”键)
  81. if (e.keyCode === 13) { // Enter key
  82. // 执行搜索操作
  83. _this.search();
  84. // 调用原生方法隐藏软键盘
  85. _this.$refs.inputField.blur();
  86. }
  87. });
  88. },
  89. watch: {
  90. searchText(value) {
  91. if (!value)
  92. this.isShow = true
  93. }
  94. },
  95. computed: {
  96. isShowApp() {
  97. // 是否是APP
  98. const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
  99. const isAndroid = this.$userAgent.isAndroid;
  100. const isIos = this.$userAgent.isIos;
  101. const isWx = this.$userAgent.isWx;
  102. // 如果是App并且是安卓,就不显示头部, ios显示
  103. // 如果微信小程序环境的,也不显示头部
  104. // 如果是h5 就显示头部
  105. let bool = false;
  106. bool = isApp && (isAndroid || isIos) ? true : false;
  107. return bool;
  108. },
  109. },
  110. methods: {
  111. pay() {
  112. this.isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser
  113. if (this.isApp && this.$userAgent.isAndroid) {
  114. window.native.startPurchase();
  115. } else if (this.isApp && this.$userAgent.isIos) {
  116. window.webkit.messageHandlers.startPurchase.postMessage({});
  117. } else if (this.$userAgent.isMiniProgram) {
  118. this.$wx.miniProgram.navigateTo({
  119. url: '/package/purchase/purchase',
  120. });
  121. } else {
  122. uni.navigateTo({
  123. url: '/package/purchase/purchase',
  124. });
  125. }
  126. },
  127. goArticleDetails(item) {
  128. this.$router.push({ path: '/introductionCloudPhone/articleDetails?token=needToken', query: { id: item.articleId } })
  129. },
  130. getSuggestApp() {
  131. this.$axios.$post('/public/v1/market/getSuggestApp', {
  132. pageNum: 1, pageSize: -1
  133. }).then((res) => {
  134. this.applicationList = res.data
  135. });
  136. },
  137. selectApplication(name) {
  138. this.searchText = name
  139. this.search()
  140. },
  141. search() {
  142. if (!this.searchText) return
  143. this.appSeatchList.slice(0, this.appSeatchList.length)
  144. this.isShow = false
  145. this.$axios.$post('/public/v1/market/clientSearchSuggestApp', { pageSize: 100, pageNum: 1, appName: this.searchText }).then((res) => {
  146. this.appSeatchList = res.data.list
  147. this.appSeatchList.forEach(element => {
  148. element.img = fileKeyToUrl(element.imageId)
  149. });
  150. });
  151. },
  152. },
  153. };
  154. </script>
  155. <style lang="less" scoped>
  156. .introduction {
  157. height: 100%;
  158. box-sizing: border-box;
  159. .introduction-title {
  160. margin-left: 10px;
  161. font-family: PingFangSC, PingFang SC;
  162. font-weight: 500;
  163. font-size: 18px;
  164. color: #cfd1d4;
  165. font-style: normal;
  166. margin-bottom: 24px;
  167. }
  168. .introduction-tips {
  169. font-family: PingFangSC, PingFang SC;
  170. font-weight: bold;
  171. font-size: 14px;
  172. color: #fefefe;
  173. font-style: normal;
  174. }
  175. .introduction-search {
  176. margin-top: 16px;
  177. height: 42px;
  178. width: 100%;
  179. background: #2c2c2d;
  180. border-radius: 8px;
  181. border: 1px solid #545660;
  182. display: flex;
  183. align-items: center;
  184. // padding: 12px 4px 4px 12px;
  185. img {
  186. margin: 12px 4px 12px 12px;
  187. vertical-align: top;
  188. width: 16px;
  189. }
  190. input {
  191. // margin-top: 8px;
  192. // vertical-align: top;
  193. height: 42px;
  194. line-height: 42px;
  195. font-size: 14px;
  196. color: #ffffff;
  197. flex: 1;
  198. }
  199. div {
  200. font-family: PingFangSC, PingFang SC;
  201. font-weight: 500;
  202. font-size: 14px;
  203. color: #3b7fff;
  204. line-height: 18px;
  205. text-align: left;
  206. font-style: normal;
  207. line-height: 37px;
  208. width: 60px;
  209. height: 34px;
  210. // background: linear-gradient(90deg, #38aefc 0%, #3b7fff 100%);
  211. float: right;
  212. text-align: center;
  213. border-radius: 1px;
  214. // border-left: 1px solid #7e8495;
  215. // margin: 4px 4px 0 0;
  216. margin: 0 4px;
  217. }
  218. }
  219. .application {
  220. padding: 0 16px;
  221. margin-top: 24px;
  222. display: grid;
  223. grid-gap: 16px;
  224. grid-template-columns: repeat(3, 1fr);
  225. & > div {
  226. font-family: PingFangSC, PingFang SC;
  227. font-weight: 400;
  228. font-size: 14px;
  229. color: #ffffff;
  230. line-height: 20px;
  231. text-align: center;
  232. font-style: normal;
  233. background: #2c2c2d;
  234. border-radius: 14px;
  235. padding: 11px 0;
  236. }
  237. }
  238. .application-list {
  239. width: 100%;
  240. background: #2c2c2d;
  241. border-radius: 12px;
  242. color: #ffffff;
  243. margin-bottom: 15px;
  244. .application-list-top {
  245. padding: 16px;
  246. }
  247. .application-list-img {
  248. width: 42px;
  249. margin-right: 8px;
  250. border-radius: 12px;
  251. }
  252. .application-list-rigth {
  253. display: inline-block;
  254. overflow: hidden;
  255. width: calc(100% - 150px);
  256. }
  257. .application-list-title {
  258. vertical-align: top;
  259. font-weight: 500;
  260. font-size: 14px;
  261. color: #ffffff;
  262. font-style: normal;
  263. margin-right: 4px;
  264. .application-list-appname {
  265. max-width: calc(100% - 50px);
  266. display: inline-block;
  267. white-space: nowrap;
  268. text-overflow: ellipsis;
  269. overflow: hidden;
  270. }
  271. span {
  272. vertical-align: super;
  273. font-family: PingFangSC, PingFang SC;
  274. font-weight: 400;
  275. font-size: 10px;
  276. color: #3b7fff;
  277. line-height: 14px;
  278. text-align: left;
  279. font-style: normal;
  280. }
  281. }
  282. .application-list-tips {
  283. font-family: PingFangSC, PingFang SC;
  284. font-weight: 400;
  285. font-size: 12px;
  286. color: #999999;
  287. line-height: 16px;
  288. text-align: left;
  289. font-style: normal;
  290. margin-right: 4px;
  291. white-space: nowrap;
  292. text-overflow: ellipsis;
  293. overflow: hidden;
  294. }
  295. .application-list-btn {
  296. width: 82px;
  297. height: 32px;
  298. background: linear-gradient(90deg, #38aefc 0%, #3b7fff 100%);
  299. border-radius: 8px;
  300. color: #ffffff;
  301. line-height: 32px;
  302. padding: 0 0 0 8px;
  303. float: right;
  304. font-size: 12px;
  305. img {
  306. vertical-align: middle;
  307. margin-top: -1px;
  308. }
  309. }
  310. .application-list-bottom {
  311. padding: 12px;
  312. font-family: PingFangSC, PingFang SC;
  313. font-weight: 400;
  314. font-size: 14px;
  315. color: #ffffff;
  316. line-height: 20px;
  317. text-align: left;
  318. font-style: normal;
  319. background: #333333;
  320. border-radius: 0px 0px 12px 12px;
  321. }
  322. }
  323. .application-default {
  324. width: 100%;
  325. text-align: center;
  326. font-family: PingFangSC, PingFang SC;
  327. font-weight: 400;
  328. font-size: 12px;
  329. color: #999999;
  330. line-height: 18px;
  331. font-style: normal;
  332. margin-top: 42px;
  333. }
  334. }
  335. .introduction-white {
  336. .introduction-title {
  337. color: #0a132b;
  338. }
  339. .introduction-tips {
  340. color: #0a132b;
  341. }
  342. .introduction-search {
  343. background: #ffffff;
  344. // border: 1px solid #ffffff;
  345. input {
  346. color: #0a132b;
  347. }
  348. div {
  349. // color: #ffffff;
  350. }
  351. }
  352. .application {
  353. & > div {
  354. color: #0a132b;
  355. background: #ffffff;
  356. }
  357. }
  358. .application-list {
  359. background: #ffffff;
  360. .application-list-title {
  361. color: #0a132b;
  362. span {
  363. color: #3b7fff;
  364. }
  365. }
  366. .application-list-tips {
  367. color: #666666;
  368. }
  369. .application-list-btn {
  370. background: linear-gradient(90deg, #38aefc 0%, #3b7fff 100%);
  371. color: #ffffff;
  372. overflow: hidden;
  373. }
  374. .application-list-bottom {
  375. color: #0a132b;
  376. background: #edeef0;
  377. }
  378. }
  379. }
  380. </style>