index.vue 9.9 KB

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