index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <section class="cert-index">
  3. <h1>开发者资质认证</h1>
  4. <div class="hr"></div>
  5. <ul class="cers">
  6. <li class="cer" v-for="item of list" :key="item.id">
  7. <section class="cer-box" :class="{'cer-check': canApply(item)}">
  8. <img :src="item.img" alt="no-img" class="cer-img" @click="clickLancer(item)" />
  9. <section class="cer-info">
  10. <h2 class="cer-title" @click="clickLancer(item)">{{item.name}}认证</h2>
  11. <div class="cer-remind" @click="clickLancer(item)">{{item.introduction}}</div>
  12. <section class="cer-price-info">
  13. <span class="price">
  14. ¥{{item.real_price}}
  15. <sub class="sub">/次</sub>
  16. </span>
  17. <span v-if="item.is_discount" class="origin-price">原价¥{{item.origin_price}}</span>
  18. <span class="vip-tag" v-if="item.is_vip_discount">会员¥{{item.vip_price}}</span>
  19. </section>
  20. <section class="cert-status">
  21. <button
  22. class="cer-ctrl"
  23. :class="{disabled: btnDisabled(item)}"
  24. :disabled="btnDisabled(item)"
  25. @click="clickLancer(item)"
  26. >{{item.btn_name}}</button>
  27. <span class="userful-time" v-if="canApply(item)">
  28. 有效期至{{item.end_date}}
  29. <nuxt-link class="link-check" :to="`/cert/no/${item.cert_no}`">查看证书</nuxt-link>
  30. </span>
  31. </section>
  32. </section>
  33. </section>
  34. <div class="line"></div>
  35. </li>
  36. </ul>
  37. </section>
  38. </template>
  39. <script>
  40. import WxMixin from "@/mixins/wx";
  41. let page = 1;
  42. export default {
  43. data() {
  44. return {
  45. title: "开发者资质认证- 程序员客栈",
  46. list: []
  47. };
  48. },
  49. head() {
  50. return {
  51. title: this.title,
  52. script: [{ src: "https://res.wx.qq.com/open/js/jweixin-1.2.0.js" }]
  53. };
  54. },
  55. mixins: [WxMixin],
  56. mounted() {
  57. this.getList();
  58. },
  59. methods: {
  60. clickLancer({ id }) {
  61. this.$router.push(`/cert/type/${id}`);
  62. },
  63. btnDisabled(item) {
  64. return item.btn_name !== "申请认证" || !item.can_click;
  65. },
  66. async getList() {
  67. let res = await this.$axios.$post(
  68. "/api/cert/getList",
  69. { page },
  70. { neverLogout: true }
  71. );
  72. if (res.status) {
  73. let list = res.data.list;
  74. this.list = list;
  75. }
  76. },
  77. canApply(item) {
  78. return item.end_date && item.is_cert_validate && item.cert_no;
  79. },
  80. configWx() {
  81. try {
  82. let conf = this.$store.state.wxConfig;
  83. wx.ready(function() {
  84. //需在用户可能点击分享按钮前就先调用
  85. wx.config({
  86. debug: true,
  87. appId: conf.appId,
  88. timestamp: conf.timestamp,
  89. nonceStr: conf.nonceStr,
  90. signature: conf.signature,
  91. jsApiList: [
  92. // 所有要调用的 API 都要加到这个列表中
  93. "onMenuShareTimeline", // 分享到朋友圈接口
  94. "onMenuShareAppMessage", // 分享到朋友接口
  95. "onMenuShareQQ", // 分享到QQ接口
  96. "onMenuShareWeibo" // 分享到微博接口
  97. ],
  98. success: function() {
  99. alert("wx.config ok");
  100. },
  101. error: function(d) {
  102. alert("wx.config err:" + JSON.stringify(d));
  103. }
  104. });
  105. wx.updateAppMessageShareData({
  106. title: "开发者资质认证", // 分享标题
  107. desc: "通过平台审核、认证,将获得更多接单机会", // 分享描述
  108. link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  109. imgUrl: "https://stacdn.proginn.com/favicon.ico", // 分享图标
  110. success: function() {
  111. // 设置成功
  112. alert("微信图标设置成功");
  113. }
  114. });
  115. });
  116. } catch (error) {
  117. alert(error);
  118. }
  119. }
  120. }
  121. };
  122. </script>
  123. <style scoped>
  124. @import "@/assets/css/h1_line.css";
  125. .cert-index {
  126. width: 100%;
  127. max-width: 1000px;
  128. min-height: 591px;
  129. background: white;
  130. border-radius: 4px;
  131. margin: 20px 0 0;
  132. padding: 8px;
  133. overflow-x: hidden;
  134. }
  135. .cers {
  136. padding: 20px 0 0;
  137. }
  138. .cers::-webkit-scrollbar {
  139. display: none;
  140. }
  141. .cer-box {
  142. position: relative;
  143. display: flex;
  144. margin-top: 26px;
  145. }
  146. .cer-img {
  147. width: 270px;
  148. height: 190px;
  149. margin-right: 6px;
  150. box-sizing: border-box;
  151. padding: 20px;
  152. cursor: pointer;
  153. }
  154. .cer-info {
  155. display: flex;
  156. flex-direction: column;
  157. }
  158. .cer-title {
  159. font-size: 18px;
  160. font-family: PingFangSC-Semibold;
  161. font-weight: 600;
  162. color: rgba(51, 51, 51, 1);
  163. line-height: 25px;
  164. margin-top: 20px;
  165. cursor: pointer;
  166. }
  167. .cer-title:hover {
  168. color: #308eff;
  169. }
  170. .cer-remind {
  171. font-size: 14px;
  172. font-family: PingFangSC-Regular;
  173. color: rgba(153, 153, 153, 1);
  174. margin: 6px 0 18px;
  175. }
  176. .price {
  177. font-size: 24px;
  178. font-family: PingFangSC-Semibold;
  179. font-weight: 600;
  180. color: rgba(34, 34, 34, 1);
  181. }
  182. .sub {
  183. margin: 0 0 0 -6px;
  184. }
  185. .origin-price {
  186. font-size: 12px;
  187. font-family: PingFangSC-Regular;
  188. color: rgba(153, 153, 153, 1);
  189. line-height: 17px;
  190. text-decoration: line-through;
  191. }
  192. .vip-tag {
  193. display: inline-flex;
  194. justify-content: center;
  195. align-items: center;
  196. width: 72px;
  197. height: 22px;
  198. font-size: 12px;
  199. font-family: PingFangSC-Semibold;
  200. font-weight: 600;
  201. color: #ddaf5a;
  202. background: url(~@/assets/img/cert/vip-tag.png) 0 0 / 100% no-repeat;
  203. padding: 0;
  204. }
  205. .cer-ctrl {
  206. margin: 10px 0 0;
  207. height: 40px;
  208. background: #0093fd;
  209. font-size: 14px;
  210. font-family: PingFangSC-Medium;
  211. font-weight: 500;
  212. color: white;
  213. }
  214. .disabled {
  215. background: #ececec;
  216. color: #666;
  217. }
  218. .userful-time {
  219. font-size: 13px;
  220. font-family: PingFangSC-Regular;
  221. color: rgba(153, 153, 153, 1);
  222. }
  223. .link-check {
  224. color: var(--mainColor);
  225. }
  226. /* 以下为了兼容移动端,样式比较坑,注意。 */
  227. @media screen and (min-width: 960px) {
  228. .cer-remind {
  229. width: 680px;
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. white-space: nowrap;
  233. }
  234. .cer-ctrl {
  235. width: 154px;
  236. }
  237. }
  238. @media screen and (max-width: 960px) {
  239. .cert-index {
  240. padding: 0;
  241. }
  242. .cer-box {
  243. height: 160px;
  244. padding: 0 8px;
  245. }
  246. .cer-check {
  247. height: 200px;
  248. }
  249. .cer-img {
  250. width: 135px;
  251. height: 90px;
  252. padding: 0;
  253. }
  254. .cer-info {
  255. flex: 1;
  256. }
  257. .cer-title {
  258. margin-top: 0;
  259. }
  260. .cer-remind {
  261. display: -webkit-box;
  262. -webkit-box-orient: vertical;
  263. -webkit-line-clamp: 3;
  264. font-size: 12px;
  265. min-height: 48px;
  266. }
  267. .cer-price-info {
  268. position: absolute;
  269. left: 8px;
  270. top: 114px;
  271. }
  272. .cert-status {
  273. text-align: right;
  274. }
  275. .cer-ctrl {
  276. width: 100px;
  277. border-radius: 40px;
  278. }
  279. .userful-time {
  280. position: absolute;
  281. bottom: 0px;
  282. left: 0;
  283. display: flex;
  284. justify-content: space-between;
  285. width: 100%;
  286. border-top: 1px solid #eee;
  287. padding: 14px;
  288. }
  289. .line {
  290. height: 8px;
  291. background: #eee;
  292. }
  293. }
  294. </style>