index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. this.getSuggestApp()
  72. let _this = this
  73. document.addEventListener('keydown', function (e) {
  74. // 检查是否是搜索键(通常是“Enter”键)
  75. if (e.keyCode === 13) { // Enter key
  76. // 执行搜索操作
  77. _this.search();
  78. // 调用原生方法隐藏软键盘
  79. _this.$refs.inputField.blur();
  80. }
  81. });
  82. },
  83. watch: {
  84. searchText(value) {
  85. if (!value)
  86. this.isShow = true
  87. }
  88. },
  89. computed: {
  90. isShowApp() {
  91. // 是否是APP
  92. const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
  93. const isAndroid = this.$userAgent.isAndroid;
  94. const isIos = this.$userAgent.isIos;
  95. const isWx = this.$userAgent.isWx;
  96. // 如果是App并且是安卓,就不显示头部, ios显示
  97. // 如果微信小程序环境的,也不显示头部
  98. // 如果是h5 就显示头部
  99. let bool = false;
  100. bool = isApp && (isAndroid || isIos) ? true : false;
  101. return bool;
  102. },
  103. },
  104. methods: {
  105. pay() {
  106. this.isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser
  107. if (this.isApp && this.$userAgent.isAndroid) {
  108. window.native.startPurchase();
  109. } else if (this.isApp && this.$userAgent.isIos) {
  110. window.webkit.messageHandlers.startPurchase.postMessage({});
  111. } else if (this.$userAgent.isMiniProgram) {
  112. this.$wx.miniProgram.navigateTo({
  113. url: '/package/purchase/purchase',
  114. });
  115. } else {
  116. uni.navigateTo({
  117. url: '/package/purchase/purchase',
  118. });
  119. }
  120. },
  121. goArticleDetails(item) {
  122. this.$router.push({ path: '/introductionCloudPhone/articleDetails?token=needToken', query: { id: item.articleId } })
  123. },
  124. getSuggestApp() {
  125. this.$axios.$post('/public/v1/market/getSuggestApp', {
  126. pageNum: 1, pageSize: -1
  127. }).then((res) => {
  128. this.applicationList = res.data
  129. });
  130. },
  131. selectApplication(name) {
  132. this.searchText = name
  133. this.search()
  134. },
  135. search() {
  136. if (!this.searchText) return
  137. this.appSeatchList.slice(0, this.appSeatchList.length)
  138. this.isShow = false
  139. this.$axios.$post('/public/v1/market/clientSearchSuggestApp', { pageSize: 100, pageNum: 1, appName: this.searchText }).then((res) => {
  140. this.appSeatchList = res.data.list
  141. this.appSeatchList.forEach(element => {
  142. element.img = fileKeyToUrl(element.imageId)
  143. });
  144. });
  145. },
  146. },
  147. };
  148. </script>
  149. <style lang="less" scoped>
  150. .introduction {
  151. height: 100%;
  152. box-sizing: border-box;
  153. .introduction-title {
  154. margin-left: 10px;
  155. font-family: PingFangSC, PingFang SC;
  156. font-weight: 500;
  157. font-size: 18px;
  158. color: #cfd1d4;
  159. font-style: normal;
  160. margin-bottom: 24px;
  161. }
  162. .introduction-tips {
  163. font-family: PingFangSC, PingFang SC;
  164. font-weight: bold;
  165. font-size: 14px;
  166. color: #fefefe;
  167. font-style: normal;
  168. }
  169. .introduction-search {
  170. margin-top: 16px;
  171. height: 42px;
  172. width: 100%;
  173. background: #2c2c2d;
  174. border-radius: 8px;
  175. border: 1px solid #545660;
  176. display: flex;
  177. align-items: center;
  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. color: #ffffff;
  191. flex: 1;
  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. margin: 0 4px;
  207. }
  208. }
  209. .application {
  210. padding: 0 16px;
  211. margin-top: 24px;
  212. display: grid;
  213. grid-gap: 16px;
  214. grid-template-columns: repeat(3, 1fr);
  215. & > div {
  216. font-family: PingFangSC, PingFang SC;
  217. font-weight: 400;
  218. font-size: 14px;
  219. color: #ffffff;
  220. line-height: 20px;
  221. text-align: center;
  222. font-style: normal;
  223. background: #2c2c2d;
  224. border-radius: 14px;
  225. padding: 11px 0;
  226. }
  227. }
  228. .application-list {
  229. width: 100%;
  230. background: #2c2c2d;
  231. border-radius: 12px;
  232. color: #ffffff;
  233. margin-bottom: 15px;
  234. .application-list-top {
  235. padding: 16px;
  236. }
  237. .application-list-img {
  238. width: 42px;
  239. margin-right: 8px;
  240. border-radius: 12px;
  241. }
  242. .application-list-rigth {
  243. display: inline-block;
  244. overflow: hidden;
  245. }
  246. .application-list-title {
  247. vertical-align: top;
  248. font-weight: 500;
  249. font-size: 14px;
  250. color: #ffffff;
  251. font-style: normal;
  252. margin-right: 4px;
  253. span {
  254. font-family: PingFangSC, PingFang SC;
  255. font-weight: 400;
  256. font-size: 10px;
  257. color: #3b7fff;
  258. line-height: 14px;
  259. text-align: left;
  260. font-style: normal;
  261. }
  262. }
  263. .application-list-tips {
  264. font-family: PingFangSC, PingFang SC;
  265. font-weight: 400;
  266. font-size: 12px;
  267. color: #999999;
  268. line-height: 16px;
  269. text-align: left;
  270. font-style: normal;
  271. margin-right: 4px;
  272. }
  273. .application-list-btn {
  274. width: 82px;
  275. height: 32px;
  276. background: linear-gradient(90deg, #38aefc 0%, #3b7fff 100%);
  277. border-radius: 8px;
  278. color: #ffffff;
  279. line-height: 32px;
  280. padding: 0 8px;
  281. float: right;
  282. font-size: 10px;
  283. img {
  284. vertical-align: middle;
  285. margin-top: -1px;
  286. }
  287. }
  288. .application-list-bottom {
  289. padding: 12px;
  290. font-family: PingFangSC, PingFang SC;
  291. font-weight: 400;
  292. font-size: 14px;
  293. color: #ffffff;
  294. line-height: 20px;
  295. text-align: left;
  296. font-style: normal;
  297. background: #333333;
  298. border-radius: 0px 0px 12px 12px;
  299. }
  300. }
  301. .application-default {
  302. width: 100%;
  303. text-align: center;
  304. font-family: PingFangSC, PingFang SC;
  305. font-weight: 400;
  306. font-size: 12px;
  307. color: #999999;
  308. line-height: 18px;
  309. font-style: normal;
  310. margin-top: 42px;
  311. }
  312. }
  313. .introduction-white {
  314. .introduction-title {
  315. color: #0a132b;
  316. }
  317. .introduction-tips {
  318. color: #0a132b;
  319. }
  320. .introduction-search {
  321. background: #ffffff;
  322. border: 1px solid #ffffff;
  323. input {
  324. color: #0a132b;
  325. }
  326. div {
  327. color: #ffffff;
  328. }
  329. }
  330. .application {
  331. & > div {
  332. color: #0a132b;
  333. background: #ffffff;
  334. }
  335. }
  336. .application-list {
  337. background: #ffffff;
  338. .application-list-title {
  339. color: #0a132b;
  340. span {
  341. color: #3b7fff;
  342. }
  343. }
  344. .application-list-tips {
  345. color: #666666;
  346. }
  347. .application-list-btn {
  348. background: linear-gradient(90deg, #38aefc 0%, #3b7fff 100%);
  349. color: #ffffff;
  350. }
  351. .application-list-bottom {
  352. color: #0a132b;
  353. background: #edeef0;
  354. }
  355. }
  356. }
  357. </style>