enterprise_detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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. @click="callphone"
  34. >
  35. {{ value || '-'}}
  36. </p>
  37. </view>
  38. <view
  39. class="term-value-group"
  40. v-else
  41. style="
  42. flex-direction: row;
  43. align-items: center;
  44. padding-left: 20rpx;
  45. "
  46. >
  47. <view class="flex_i">
  48. <view>
  49. {{ item.value[0] || '-'}}
  50. </view>
  51. <view v-if="item.value[0]"
  52. class="copy"
  53. @click="copy(item.value[0])"
  54. style="color: #02a7f0; margin-left: 15rpx"
  55. >复制</view
  56. >
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view v-else-if="active === 1" class="proInfo">
  63. <view class="products" v-if="productList.length !== 0">
  64. <view
  65. class="product"
  66. @click="toDetail(item.id)"
  67. v-for="(item, idx) in productList"
  68. :key="idx"
  69. >
  70. <view class="img">
  71. <image :src="'https://kiq.xazhima.com' + item.pic_url"></image>
  72. </view>
  73. <view class="name">{{ item.name || '-'}}</view>
  74. </view>
  75. </view>
  76. <view v-else class="products">
  77. <img src="/static/nodata.svg" alt="" />
  78. <div style="margin: 0 auto">暂无产品信息</div>
  79. </view>
  80. </view>
  81. <view style="width: 100%">
  82. <footer-share
  83. style="width: 100%"
  84. :isCollection="true"
  85. :isCollectedIcon="infoObj.if_collect"
  86. @collectionPages="collectionPage"
  87. @sharePages="sharePage"
  88. ></footer-share>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import md5 from "@/common/md5.js";
  94. import topTitle from "@/components/top-title/top-title.vue";
  95. import footTabs from "@/components/foot-tabs/footTabs.vue";
  96. export default {
  97. components: {
  98. "foot-tabs": footTabs,
  99. "top-title": topTitle,
  100. },
  101. data() {
  102. return {
  103. id: "",
  104. scrollTop: 0,
  105. titleList: ["基本信息", "产品信息"],
  106. active: 0,
  107. info: {},
  108. model: {},
  109. productList: [],
  110. isShow: false,
  111. infoObj: {},
  112. };
  113. },
  114. onLoad(option) {
  115. let id = option.id;
  116. this.getCompanyInfo(id);
  117. this.getProductInfo(id);
  118. },
  119. methods: {
  120. callphone(value) {
  121. if(this.info.phone){
  122. uni.makePhoneCall({
  123. phoneNumber: this.info.phone,
  124. });
  125. }
  126. },
  127. change(idx) {
  128. this.active = idx;
  129. },
  130. toDetail(index) {
  131. uni.navigateTo({
  132. url: "/pages/enterprise/product_detail?id=" + index,
  133. });
  134. },
  135. getCompanyInfo(id) {
  136. let md5Sign = md5(
  137. "method=" +
  138. "common" +
  139. "&timestamp=" +
  140. getApp().globalData.globalTimestamp +
  141. "&secret=" +
  142. getApp().globalData.secret
  143. );
  144. let url =
  145. getApp().globalData.shareUrl +
  146. "api/api.php" +
  147. "?method=common&source=company&action=info_by_id&timestamp=" +
  148. getApp().globalData.globalTimestamp +
  149. "&sign=" +
  150. md5Sign;
  151. uni.request({
  152. url: url,
  153. method: "POST",
  154. header: {
  155. "content-type": "application/x-www-form-urlencoded",
  156. },
  157. data: { id, openId: getApp().globalData.open_id },
  158. success: (res) => {
  159. if (res.data.code === 200) {
  160. this.infoObj = res.data.data;
  161. let {
  162. name,
  163. pic_url,
  164. representative,
  165. found_date,
  166. capital,
  167. code,
  168. industry_name,
  169. park_name,
  170. work_address,
  171. rigiser_address,
  172. web_url,
  173. phone,
  174. work_range,
  175. } = res.data.data;
  176. this.info = {
  177. name,
  178. pic_url,
  179. representative,
  180. found_date,
  181. capital,
  182. code,
  183. industry_name,
  184. park_name,
  185. work_address,
  186. rigiser_address,
  187. web_url,
  188. phone,
  189. work_range,
  190. };
  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. "https://kiq.xazhima.com" + 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: 30rpx;
  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. .logo {
  412. image {
  413. width: 100rpx;
  414. height: 100rpx;
  415. margin: 0 30rpx;
  416. }
  417. }
  418. }
  419. .baseInfo {
  420. margin-bottom: 50rpx;
  421. .card-title {
  422. padding: 20rpx 20rpx 0rpx 20rpx;
  423. font-weight: 600;
  424. }
  425. .item-list {
  426. margin-left: 20rpx;
  427. display: flex;
  428. flex-direction: column;
  429. .term {
  430. display: flex;
  431. .term-name {
  432. font-size: 27rpx;
  433. width: 30%;
  434. display: flex;
  435. margin: 20rpx;
  436. color: #7f7f7f;
  437. }
  438. .term-value-group {
  439. flex: 1;
  440. display: flex;
  441. flex-direction: column;
  442. font-size: 27rpx;
  443. .term-value-item {
  444. margin: 20rpx;
  445. }
  446. .flex_i {
  447. display: flex;
  448. flex-flow: row;
  449. justify-content: space-around;
  450. }
  451. }
  452. }
  453. }
  454. }
  455. .proInfo {
  456. font-size: 25rpx;
  457. .products {
  458. width: 100%;
  459. display: flex;
  460. padding: 4%;
  461. flex-wrap: wrap;
  462. .product {
  463. margin: 2%;
  464. padding: 2%;
  465. border-radius: 30rpx;
  466. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  467. width: 40%;
  468. height: 100px;
  469. display: flex;
  470. flex-flow: column;
  471. justify-content: space-between;
  472. align-items: center;
  473. .img {
  474. width: 200rpx;
  475. height: 200rpx;
  476. image {
  477. width: 200rpx;
  478. height: 160rpx;
  479. }
  480. }
  481. }
  482. }
  483. }
  484. .enterprise-item-box {
  485. display: flex;
  486. justify-content: space-evenly;
  487. margin: 0 20rpx;
  488. margin-top: 10rpx;
  489. .enterprise-item-name {
  490. padding-bottom: 10rpx;
  491. font-size: 27rpx;
  492. }
  493. .active {
  494. font-weight: 600;
  495. border-bottom: 7rpx solid #02a7f0;
  496. }
  497. }
  498. }
  499. .margin-bottom-80 {
  500. margin-bottom: 80rpx;
  501. }
  502. </style>