index.vue 9.2 KB

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