enterprise_detail.vue 12 KB

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