enterprise_detail.vue 13 KB

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