enterprise_detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="content" :class="{ 'margin-bottom-80': isMar }" v-if="isShow">
  3. <view class="title">
  4. <view class="logo">
  5. <image
  6. :src="'https://kiq.xazhima.com' + info.pic_url"
  7. alt="" class="logo-img"
  8. mode="aspectFit"
  9. ></image>
  10. </view>
  11. <view class="name">
  12. {{ info.name || "-" }}
  13. </view>
  14. </view>
  15. <view class="enterprise-item-box">
  16. <view
  17. v-for="(item, idx) in titleList"
  18. :key="idx"
  19. :class="{ active: active === idx }"
  20. class="enterprise-item-name"
  21. @click="change(idx)"
  22. >
  23. {{ item || "-" }}
  24. </view>
  25. </view>
  26. <view class="baseInfo" v-if="active === 0">
  27. <view class="card-title">{{ model.title }}</view>
  28. <view class="item-list">
  29. <view v-for="(item, idx) in model.item" :key="idx" class="term">
  30. <view class="term-name">{{ item.name }}:</view>
  31. <view class="term-value-group" v-if="item.name !== '网址'">
  32. <p
  33. v-for="(value, idx) in item.value"
  34. :key="idx"
  35. class="term-value-item"
  36. :class="{ blue: item.name == '电话' }"
  37. @click="callphone"
  38. >
  39. {{ value || "-" }}
  40. </p>
  41. </view>
  42. <view
  43. class="term-value-group"
  44. v-else
  45. style="
  46. flex-direction: row;
  47. align-items: center;
  48. padding-left: 20rpx;
  49. "
  50. >
  51. <view class="flex_i">
  52. <view>
  53. {{ item.value[0] || "-" }}
  54. </view>
  55. <view
  56. v-if="item.value[0]"
  57. class="copy"
  58. @click="copy(item.value[0])"
  59. style="color: #02a7f0; margin-left: 15rpx"
  60. >复制</view
  61. >
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view v-else-if="active === 1" class="proInfo">
  68. <view class="products" v-if="productList.length !== 0">
  69. <view
  70. class="product"
  71. @click="toDetail(item.id)"
  72. v-for="(item, idx) in productList"
  73. :key="idx"
  74. >
  75. <view class="img">
  76. <image
  77. :src="
  78. item.pic_url
  79. ? 'https://kiq.xazhima.com' + item.pic_url
  80. : '/static/enterprise/default.webp'
  81. "
  82. mode="aspectFit"
  83. ></image>
  84. </view>
  85. <view class="name">{{ item.name || "-" }}</view>
  86. </view>
  87. </view>
  88. <view v-else class="products">
  89. <img src="/static/nodata.svg" alt="" />
  90. <div style="margin: 0 auto">暂无产品信息</div>
  91. </view>
  92. </view>
  93. <view style="width: 100%">
  94. <footer-share
  95. style="width: 100%"
  96. :isCollection="true"
  97. :isCollectedIcon="infoObj.if_collect"
  98. @collectionPages="collectionPage"
  99. @sharePages="sharePage"
  100. ></footer-share>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import md5 from "@/common/md5.js";
  106. import topTitle from "@/components/top-title/top-title.vue";
  107. import footTabs from "@/components/foot-tabs/footTabs.vue";
  108. export default {
  109. components: {
  110. "foot-tabs": footTabs,
  111. "top-title": topTitle,
  112. },
  113. data() {
  114. return {
  115. id: "",
  116. scrollTop: 0,
  117. titleList: ["基本信息", "产品信息"],
  118. active: 0,
  119. info: {},
  120. model: {},
  121. productList: [],
  122. isShow: false,
  123. infoObj: {},
  124. };
  125. },
  126. onLoad(option) {
  127. let id = option.id;
  128. this.getCompanyInfo(id);
  129. this.getProductInfo(id);
  130. },
  131. methods: {
  132. callphone(value) {
  133. if (this.info.phone) {
  134. uni.makePhoneCall({
  135. phoneNumber: this.info.phone,
  136. });
  137. }
  138. },
  139. change(idx) {
  140. this.active = idx;
  141. },
  142. toDetail(index) {
  143. uni.navigateTo({
  144. url: "/pages/enterprise/product_detail?id=" + index,
  145. });
  146. },
  147. getCompanyInfo(id) {
  148. let md5Sign = md5(
  149. "method=" +
  150. "common" +
  151. "&timestamp=" +
  152. getApp().globalData.globalTimestamp +
  153. "&secret=" +
  154. getApp().globalData.secret
  155. );
  156. let url =
  157. getApp().globalData.shareUrl +
  158. "api/api.php" +
  159. "?method=common&source=company&action=info_by_id&timestamp=" +
  160. getApp().globalData.globalTimestamp +
  161. "&sign=" +
  162. md5Sign;
  163. uni.request({
  164. url: url,
  165. method: "POST",
  166. header: {
  167. "content-type": "application/x-www-form-urlencoded",
  168. },
  169. data: { id, openId: getApp().globalData.open_id },
  170. success: (res) => {
  171. if (res.data.code === 200) {
  172. this.infoObj = res.data.data;
  173. let {
  174. name,
  175. pic_url,
  176. representative,
  177. found_date,
  178. capital,
  179. code,
  180. industry_name,
  181. park_name,
  182. work_address,
  183. rigiser_address,
  184. web_url,
  185. phone,
  186. work_range,
  187. } = res.data.data;
  188. this.info = {
  189. name,
  190. pic_url,
  191. representative,
  192. found_date,
  193. capital,
  194. code,
  195. industry_name,
  196. park_name,
  197. work_address,
  198. rigiser_address,
  199. web_url,
  200. phone,
  201. work_range,
  202. };
  203. this.info.capital = this.info.capital + '万元'
  204. this.model = {
  205. title: "",
  206. item: [
  207. {
  208. name: "法定代表人",
  209. value: [this.info.representative],
  210. },
  211. {
  212. name: "成立日期",
  213. value: [this.info.found_date],
  214. },
  215. {
  216. name: "注册资本",
  217. value: [this.info.capital],
  218. },
  219. {
  220. name: "统一社会信用代码",
  221. value: [this.info.code],
  222. },
  223. {
  224. name: "所属行业",
  225. value: [this.info.industry_name],
  226. },
  227. {
  228. name: "所属园区",
  229. value: [this.info.park_name],
  230. },
  231. {
  232. name: "经营范围",
  233. value: [this.info.work_range],
  234. },
  235. {
  236. name: "地址",
  237. value: [this.info.rigiser_address],
  238. },
  239. {
  240. name: "网址",
  241. value: [this.info.web_url],
  242. },
  243. {
  244. name: "电话",
  245. value: [this.info.phone],
  246. },
  247. ],
  248. };
  249. getApp().globalData.company_name = name;
  250. getApp().globalData.company_logo =
  251. "https://kiq.xazhima.com" + pic_url;
  252. this.isShow = true;
  253. }
  254. },
  255. fail: () => {
  256. console.log("连接失败");
  257. },
  258. });
  259. },
  260. getProductInfo(id) {
  261. let md5Sign = md5(
  262. "method=" +
  263. "common" +
  264. "&timestamp=" +
  265. getApp().globalData.globalTimestamp +
  266. "&secret=" +
  267. getApp().globalData.secret
  268. );
  269. let url =
  270. getApp().globalData.shareUrl +
  271. "api/api.php" +
  272. "?method=common&action=list&source=company_product&timestamp=" +
  273. getApp().globalData.globalTimestamp +
  274. "&sign=" +
  275. md5Sign;
  276. uni.request({
  277. url: url,
  278. method: "POST",
  279. header: {
  280. "content-type": "application/x-www-form-urlencoded",
  281. },
  282. data: {
  283. s_company_id: id,
  284. },
  285. success: (res) => {
  286. if (res.data.code === 200) {
  287. this.productList = res.data.data.list;
  288. console.log(this.productList);
  289. }
  290. },
  291. fail: () => {
  292. console.log("连接失败");
  293. },
  294. });
  295. },
  296. goAuthPage() {
  297. uni.navigateTo({
  298. url: "../auth/index",
  299. });
  300. },
  301. collectionPage() {
  302. if (!getApp().globalData.user_phone) {
  303. this.goAuthPage();
  304. return;
  305. }
  306. let md5Sign = md5(
  307. "method=" +
  308. "user" +
  309. "&timestamp=" +
  310. getApp().globalData.globalTimestamp +
  311. "&secret=" +
  312. getApp().globalData.secret
  313. );
  314. let url =
  315. getApp().globalData.shareUrl +
  316. "api/api.php" +
  317. "?method=user&source=company&action=collect_add&timestamp=" +
  318. getApp().globalData.globalTimestamp +
  319. "&sign=" +
  320. md5Sign;
  321. uni.request({
  322. url: url,
  323. method: "POST",
  324. header: {
  325. "content-type": "application/x-www-form-urlencoded",
  326. },
  327. data: {
  328. openId: getApp().globalData.open_id,
  329. source: "company",
  330. source_name: "企业",
  331. source_id: this.infoObj.id,
  332. source_title: this.infoObj.name,
  333. },
  334. success: (res) => {
  335. if (res.data.code === 200) {
  336. res.data.data
  337. ? (this.infoObj.if_collect = true)
  338. : (this.infoObj.if_collect = false);
  339. this.$forceUpdate();
  340. uni.showToast({
  341. duration: 3000,
  342. title: res.data.msg,
  343. icon: "none",
  344. });
  345. }
  346. },
  347. fail: () => {
  348. console.log("连接失败");
  349. },
  350. });
  351. },
  352. shareRequest() {
  353. let md5Sign = md5(
  354. "method=" +
  355. "user" +
  356. "&timestamp=" +
  357. getApp().globalData.globalTimestamp +
  358. "&secret=" +
  359. getApp().globalData.secret
  360. );
  361. let url =
  362. getApp().globalData.shareUrl +
  363. "api/api.php" +
  364. "?method=user&source=company&action=repost&timestamp=" +
  365. getApp().globalData.globalTimestamp +
  366. "&sign=" +
  367. md5Sign;
  368. uni.request({
  369. url: url,
  370. method: "POST",
  371. header: {
  372. "content-type": "application/x-www-form-urlencoded",
  373. },
  374. data: {
  375. openId: getApp().globalData.open_id,
  376. source_id: this.infoObj.id,
  377. source: "company",
  378. },
  379. success: (res) => {
  380. if (res.data.code === 200) {
  381. console.log(res);
  382. }
  383. },
  384. fail: () => {
  385. console.log("连接失败");
  386. },
  387. });
  388. },
  389. sharePage() {
  390. let that = this;
  391. uni.showShareMenu({
  392. title: that.infoObj.title,
  393. path: "pages/enterprise/enterprise_detail?id=" + that.infoObj.id,
  394. success(res) {
  395. that.shareRequest();
  396. },
  397. });
  398. },
  399. copy(data) {
  400. uni.setClipboardData({
  401. data,
  402. success: function () {
  403. console.log("复制成功");
  404. },
  405. });
  406. },
  407. },
  408. };
  409. </script>
  410. <style lang="scss" scoped>
  411. .content {
  412. padding: 4%;
  413. font-size: 30rpx;
  414. .blue {
  415. color: #02a7f0;
  416. }
  417. .title {
  418. display: flex;
  419. align-items: center;
  420. border-radius: 10rpx;
  421. margin-bottom: 50rpx;
  422. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  423. height: 150rpx;
  424. padding: 0 20rpx;
  425. .logo {
  426. width: 150rpx;
  427. height: 100rpx;
  428. .logo-img {
  429. max-width: 100%;
  430. max-height: 100%;
  431. }
  432. }
  433. .name{
  434. margin-left: 30rpx;
  435. }
  436. }
  437. .baseInfo {
  438. margin-bottom: 50rpx;
  439. .card-title {
  440. padding: 20rpx 20rpx 0rpx 20rpx;
  441. font-weight: 600;
  442. }
  443. .item-list {
  444. margin-left: 20rpx;
  445. display: flex;
  446. flex-direction: column;
  447. .term {
  448. display: flex;
  449. .term-name {
  450. font-size: 27rpx;
  451. width: 30%;
  452. display: flex;
  453. margin: 20rpx;
  454. color: #7f7f7f;
  455. }
  456. .term-value-group {
  457. flex: 1;
  458. display: flex;
  459. flex-direction: column;
  460. font-size: 27rpx;
  461. .term-value-item {
  462. margin: 20rpx;
  463. }
  464. .flex_i {
  465. display: flex;
  466. flex-flow: row;
  467. justify-content: space-around;
  468. }
  469. }
  470. }
  471. }
  472. }
  473. .proInfo {
  474. font-size: 25rpx;
  475. .products {
  476. width: 100%;
  477. display: flex;
  478. padding: 4%;
  479. flex-wrap: wrap;
  480. .product {
  481. margin: 2%;
  482. padding: 2%;
  483. border-radius: 30rpx;
  484. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  485. width: 40%;
  486. height: 100px;
  487. display: flex;
  488. flex-flow: column;
  489. justify-content: space-between;
  490. align-items: center;
  491. .img {
  492. width: 200rpx;
  493. height: 200rpx;
  494. image {
  495. width: 200rpx;
  496. height: 160rpx;
  497. }
  498. }
  499. }
  500. }
  501. }
  502. .enterprise-item-box {
  503. display: flex;
  504. justify-content: space-evenly;
  505. margin: 0 20rpx;
  506. margin-top: 10rpx;
  507. .enterprise-item-name {
  508. padding-bottom: 10rpx;
  509. font-size: 27rpx;
  510. }
  511. .active {
  512. font-weight: 600;
  513. border-bottom: 7rpx solid #02a7f0;
  514. }
  515. }
  516. }
  517. .margin-bottom-80 {
  518. margin-bottom: 80rpx;
  519. }
  520. </style>