index.vue 9.5 KB

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