enterprise_detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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.model = {
  204. title: "",
  205. item: [
  206. {
  207. name: "法定代表人",
  208. value: [this.info.representative],
  209. },
  210. {
  211. name: "成立日期",
  212. value: [this.info.found_date],
  213. },
  214. {
  215. name: "注册资本",
  216. value: [this.info.capital],
  217. },
  218. {
  219. name: "统一社会信用代码",
  220. value: [this.info.code],
  221. },
  222. {
  223. name: "所属行业",
  224. value: [this.info.industry_name],
  225. },
  226. {
  227. name: "所属园区",
  228. value: [this.info.park_name],
  229. },
  230. {
  231. name: "经营范围",
  232. value: [this.info.work_range],
  233. },
  234. {
  235. name: "地址",
  236. value: [this.info.rigiser_address],
  237. },
  238. {
  239. name: "网址",
  240. value: [this.info.web_url],
  241. },
  242. {
  243. name: "电话",
  244. value: [this.info.phone],
  245. },
  246. ],
  247. };
  248. getApp().globalData.company_name = name;
  249. getApp().globalData.company_logo =
  250. "https://kiq.xazhima.com" + pic_url;
  251. this.isShow = true;
  252. }
  253. },
  254. fail: () => {
  255. console.log("连接失败");
  256. },
  257. });
  258. },
  259. getProductInfo(id) {
  260. let md5Sign = md5(
  261. "method=" +
  262. "common" +
  263. "&timestamp=" +
  264. getApp().globalData.globalTimestamp +
  265. "&secret=" +
  266. getApp().globalData.secret
  267. );
  268. let url =
  269. getApp().globalData.shareUrl +
  270. "api/api.php" +
  271. "?method=common&action=list&source=company_product&timestamp=" +
  272. getApp().globalData.globalTimestamp +
  273. "&sign=" +
  274. md5Sign;
  275. uni.request({
  276. url: url,
  277. method: "POST",
  278. header: {
  279. "content-type": "application/x-www-form-urlencoded",
  280. },
  281. data: {
  282. s_company_id: id,
  283. },
  284. success: (res) => {
  285. if (res.data.code === 200) {
  286. this.productList = res.data.data.list;
  287. console.log(this.productList);
  288. }
  289. },
  290. fail: () => {
  291. console.log("连接失败");
  292. },
  293. });
  294. },
  295. goAuthPage() {
  296. uni.navigateTo({
  297. url: "../auth/index",
  298. });
  299. },
  300. collectionPage() {
  301. if (!getApp().globalData.user_phone) {
  302. this.goAuthPage();
  303. return;
  304. }
  305. let md5Sign = md5(
  306. "method=" +
  307. "user" +
  308. "&timestamp=" +
  309. getApp().globalData.globalTimestamp +
  310. "&secret=" +
  311. getApp().globalData.secret
  312. );
  313. let url =
  314. getApp().globalData.shareUrl +
  315. "api/api.php" +
  316. "?method=user&source=company&action=collect_add&timestamp=" +
  317. getApp().globalData.globalTimestamp +
  318. "&sign=" +
  319. md5Sign;
  320. uni.request({
  321. url: url,
  322. method: "POST",
  323. header: {
  324. "content-type": "application/x-www-form-urlencoded",
  325. },
  326. data: {
  327. openId: getApp().globalData.open_id,
  328. source: "company",
  329. source_name: "企业",
  330. source_id: this.infoObj.id,
  331. source_title: this.infoObj.name,
  332. },
  333. success: (res) => {
  334. if (res.data.code === 200) {
  335. res.data.data
  336. ? (this.infoObj.if_collect = true)
  337. : (this.infoObj.if_collect = false);
  338. this.$forceUpdate();
  339. uni.showToast({
  340. duration: 3000,
  341. title: res.data.msg,
  342. icon: "none",
  343. });
  344. }
  345. },
  346. fail: () => {
  347. console.log("连接失败");
  348. },
  349. });
  350. },
  351. shareRequest() {
  352. let md5Sign = md5(
  353. "method=" +
  354. "user" +
  355. "&timestamp=" +
  356. getApp().globalData.globalTimestamp +
  357. "&secret=" +
  358. getApp().globalData.secret
  359. );
  360. let url =
  361. getApp().globalData.shareUrl +
  362. "api/api.php" +
  363. "?method=user&source=company&action=repost&timestamp=" +
  364. getApp().globalData.globalTimestamp +
  365. "&sign=" +
  366. md5Sign;
  367. uni.request({
  368. url: url,
  369. method: "POST",
  370. header: {
  371. "content-type": "application/x-www-form-urlencoded",
  372. },
  373. data: {
  374. openId: getApp().globalData.open_id,
  375. source_id: this.infoObj.id,
  376. source: "company",
  377. },
  378. success: (res) => {
  379. if (res.data.code === 200) {
  380. console.log(res);
  381. }
  382. },
  383. fail: () => {
  384. console.log("连接失败");
  385. },
  386. });
  387. },
  388. sharePage() {
  389. let that = this;
  390. uni.showShareMenu({
  391. title: that.infoObj.title,
  392. path: "pages/enterprise/enterprise_detail?id=" + that.infoObj.id,
  393. success(res) {
  394. that.shareRequest();
  395. },
  396. });
  397. },
  398. copy(data) {
  399. uni.setClipboardData({
  400. data,
  401. success: function () {
  402. console.log("复制成功");
  403. },
  404. });
  405. },
  406. },
  407. };
  408. </script>
  409. <style lang="scss" scoped>
  410. .content {
  411. padding: 4%;
  412. font-size: 30rpx;
  413. .blue {
  414. color: #02a7f0;
  415. }
  416. .title {
  417. display: flex;
  418. align-items: center;
  419. border-radius: 10rpx;
  420. margin-bottom: 50rpx;
  421. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  422. height: 150rpx;
  423. padding: 0 20rpx;
  424. .logo {
  425. width: 150rpx;
  426. height: 100rpx;
  427. .logo-img {
  428. max-width: 100%;
  429. max-height: 100%;
  430. }
  431. }
  432. .name{
  433. margin-left: 30rpx;
  434. }
  435. }
  436. .baseInfo {
  437. margin-bottom: 50rpx;
  438. .card-title {
  439. padding: 20rpx 20rpx 0rpx 20rpx;
  440. font-weight: 600;
  441. }
  442. .item-list {
  443. margin-left: 20rpx;
  444. display: flex;
  445. flex-direction: column;
  446. .term {
  447. display: flex;
  448. .term-name {
  449. font-size: 27rpx;
  450. width: 30%;
  451. display: flex;
  452. margin: 20rpx;
  453. color: #7f7f7f;
  454. }
  455. .term-value-group {
  456. flex: 1;
  457. display: flex;
  458. flex-direction: column;
  459. font-size: 27rpx;
  460. .term-value-item {
  461. margin: 20rpx;
  462. }
  463. .flex_i {
  464. display: flex;
  465. flex-flow: row;
  466. justify-content: space-around;
  467. }
  468. }
  469. }
  470. }
  471. }
  472. .proInfo {
  473. font-size: 25rpx;
  474. .products {
  475. width: 100%;
  476. display: flex;
  477. padding: 4%;
  478. flex-wrap: wrap;
  479. .product {
  480. margin: 2%;
  481. padding: 2%;
  482. border-radius: 30rpx;
  483. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  484. width: 40%;
  485. height: 100px;
  486. display: flex;
  487. flex-flow: column;
  488. justify-content: space-between;
  489. align-items: center;
  490. .img {
  491. width: 200rpx;
  492. height: 200rpx;
  493. image {
  494. width: 200rpx;
  495. height: 160rpx;
  496. }
  497. }
  498. }
  499. }
  500. }
  501. .enterprise-item-box {
  502. display: flex;
  503. justify-content: space-evenly;
  504. margin: 0 20rpx;
  505. margin-top: 10rpx;
  506. .enterprise-item-name {
  507. padding-bottom: 10rpx;
  508. font-size: 27rpx;
  509. }
  510. .active {
  511. font-weight: 600;
  512. border-bottom: 7rpx solid #02a7f0;
  513. }
  514. }
  515. }
  516. .margin-bottom-80 {
  517. margin-bottom: 80rpx;
  518. }
  519. </style>