enterprise_detail.vue 13 KB

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