detail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view>
  3. <view v-if="(shop || null) != null" class="pr">
  4. <!-- 搜索 -->
  5. <view :class="'padding-main bg-white pr oh br-b search '+(is_shop_whole_search == 1 ? '' : 'header-shop-whole-search')">
  6. <input class="bg-white fl padding-left-xxl text-size-xs round border-color-main" type="done" placeholder="请输入您搜索的商品关键字" :value="search_keywords_value || ''" placeholder-class="cr-grey" @input="search_keywords_event">
  7. <view class="search-btn pa">
  8. <button class="bg-main br-main cr-white round text-size-xs" type="default" size="mini" hover-class="none" @tap="search_button_event" :data-value="'/pages/plugins/shop/search/search?shop_id='+shop.id+'&'">{{is_shop_whole_search == 1 ? '搜本店' : '搜索'}}</button>
  9. <button v-if="is_shop_whole_search == 1" class="bg-main-pair br-main-pair cr-white round text-size-xs" type="default" size="mini" hover-class="none" @tap="search_button_event" data-value="/pages/goods-search/goods-search?">搜全站</button>
  10. </view>
  11. </view>
  12. <!-- 顶部 -->
  13. <view class="header plugins-shop-data-list bg-white oh">
  14. <image :src="shop.logo_long" mode="widthFix" class="shop-logo fl br-r padding-right-lg margin-top-xs cp"></image>
  15. <view class="base fr item">
  16. <view class="shop-title single-text">
  17. <!-- 认证信息 -->
  18. <view v-if="(data_base.is_enable_auth || 0) == 1 && ((shop.auth_type != -1 && (shop.auth_type_msg || null) != null) || ((shop.bond_status || 0) == 1 && (shop.bond_status_msg || null) != null))" class="auth-icon dis-inline-block">
  19. <!-- 实名认证 -->
  20. <block v-if="shop.auth_type != -1 && (shop.auth_type_msg || null) != null">
  21. <block v-if="shop.auth_type == 0">
  22. <image :src="data_base.shop_auth_personal_icon" class="icon va-m" mode="aspectFill"></image>
  23. </block>
  24. <block v-if="shop.auth_type == 1">
  25. <image :src="data_base.shop_auth_company_icon" class="icon va-m" mode="aspectFill"></image>
  26. </block>
  27. </block>
  28. <!-- 保证金认证 -->
  29. <block v-if="(shop.bond_status || 0) == 1 && (shop.bond_status_msg || null) != null">
  30. <image :src="data_base.shop_auth_bond_icon" class="icon va-m" mode="aspectFill"></image>
  31. </block>
  32. </view>
  33. <!-- 标题 -->
  34. <text class="fw-b text-size va-m">{{shop.name}}</text>
  35. </view>
  36. <view class="base-bottom oh margin-top-sm">
  37. <view v-if="(data_base.is_service_info || 0) == 1" class="fl margin-right-xxl cp" @tap="header_service_event">
  38. <image class="va-m margin-right-sm" :src="common_static_url+'customer-service-icon.png'" mode="scaleToFill"></image>
  39. <text class="va-m cr-base">在线客服</text>
  40. </view>
  41. <view class="fl single-text cp" @tap="shop_favor_event">
  42. <image class="va-m margin-right-sm" :src="common_static_url+'favor'+(shop_favor_info.status == 1 ? '-active' : '')+'-icon.png'" mode="scaleToFill"></image>
  43. <text :class="'va-m ' + (shop_favor_info.status == 1 ? 'cr-main' : '')">{{shop_favor_info.text}}({{shop_favor_info.count}})</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 在线客服 -->
  49. <view v-if="header_service_status && ((data_base.is_service_info || 0) == 1 || (shop.chat_info || null) != null)" class="header-service pa border-radius-main oh bg-white br">
  50. <view v-if="(shop.chat_info || null) != null" class="item padding-main br-t single-text">
  51. <text class="va-m">客服:</text>
  52. <view class="dis-inline-block chat-info cp" @tap="chat_event">
  53. <image class="dis-inline-block va-m" :src="shop.chat_info.icon" mode="scaleToFill"></image>
  54. <text class="margin-left-sm va-m cr-blue" :data-value="shop.chat_info.chat_url">{{shop.chat_info.name}}</text>
  55. </view>
  56. </view>
  57. <view v-if="(shop.service_qq || null) != null" class="item padding-main br-t single-text">
  58. <text>Q Q:</text>
  59. <text class="cp" @tap="text_copy_event" :data-value="shop.service_qq">{{shop.service_qq}}</text>
  60. </view>
  61. <view v-if="(shop.service_tel || null) != null" class="item padding-main br-t single-text">
  62. <text>电话:</text>
  63. <text class="cp" @tap="tel_event" :data-value="shop.service_tel">{{shop.service_tel}}</text>
  64. </view>
  65. <view v-if="(shop.open_week_name || null) != null && (shop.close_week_name || null) != null" class="item padding-main br-t single-text">
  66. <text>时间:</text>
  67. <text class="cp" @tap="text_copy_event" :data-value="shop.open_week_name + '至' + shop.close_week_name + ',' + shop.open_time + '-' + shop.close_time">{{shop.open_week_name}}至{{shop.close_week_name}},{{shop.open_time}}-{{shop.close_time}}</text>
  68. </view>
  69. <view v-if="(shop.service_weixin_qrcode || null) != null || (shop.service_line_qrcode || null) != null" class="oh qrcode tc br-t">
  70. <view v-if="(shop.service_weixin_qrcode || null) != null" class="item padding-bottom-lg dis-inline-block">
  71. <image class="radius cp" :src="shop.service_weixin_qrcode" mode="scaleToFill" @tap="image_show_event" :data-value="shop.service_weixin_qrcode"></image>
  72. <view>长按微信咨询</view>
  73. </view>
  74. <view v-if="(shop.service_line_qrcode || null) != null" class="item padding-bottom-lg dis-inline-block">
  75. <image class="radius cp" :src="shop.service_line_qrcode" mode="scaleToFill" @tap="image_show_event" :data-value="shop.service_line_qrcode"></image>
  76. <view>长按line咨询</view>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 导航 -->
  81. <view v-if="shop_goods_category.length > 0 || shop_navigation.length > 0" class="nav scroll-view-horizontal bg-white padding-top-lg border-color-main">
  82. <view v-if="shop_goods_category.length > 0" class="item padding-main arrow-bottom nav-shop-category dis-inline-block fw-b cp" @tap="nav_shop_category_event">查看商品分类</view>
  83. <scroll-view scroll-x class="nav-scroll">
  84. <block v-if="shop_navigation.length > 0">
  85. <block v-for="(item, index) in shop_navigation" :key="index">
  86. <view class="item dis-inline-block fw-b cp" @tap="nav_event" :data-value="item.url" :data-index="index">{{item.name}}</view>
  87. </block>
  88. </block>
  89. </scroll-view>
  90. <view v-if="nav_category_status" class="nav-category bg-white pa tc">
  91. <scroll-view scroll-y class="category-scroll">
  92. <block v-if="shop_goods_category.length > 0">
  93. <block v-for="(item, index) in shop_goods_category" :key="index">
  94. <view class="item dis-block cr-base single-text cp" @tap="shop_category_event" :data-value="item.id">{{item.name}}</view>
  95. </block>
  96. </block>
  97. <block v-else>
  98. <view class="padding-top-xxl padding-bottom-xxl cr-grey">暂无数据</view>
  99. </block>
  100. </scroll-view>
  101. </view>
  102. </view>
  103. <!-- 数据模式 -->
  104. <!-- 自动模式 -->
  105. <block v-if="(shop.data_model || 0) == 0">
  106. <view v-if="(data || null) != null && data.length > 0" class="padding-main oh">
  107. <component-goods-list :propData="{style_type: 1, goods_list: data}" :propCurrencySymbol="currency_symbol"></component-goods-list>
  108. <button class="bg-main br-main cr-white round dis-block margin-top-xl margin-bottom-xl margin-horizontal-main" @tap="url_event" :data-value="'/pages/plugins/shop/search/search?shop_id='+shop.id" size="mini">查看更多商品 >></button>
  109. </view>
  110. <block v-else>
  111. <component-no-data propStatus="0"></component-no-data>
  112. </block>
  113. </block>
  114. <!-- 标准模式 -->
  115. <block v-if="(shop.data_model || 0) == 1">
  116. <block v-if="((slider || null) != null && slider.length > 0) || ((data || null) != null && data.length > 0)">
  117. <view class="data-list padding-horizontal-main oh">
  118. <!-- 轮播 -->
  119. <view v-if="slider.length > 0" class="margin-top-main">
  120. <component-banner :propData="slider"></component-banner>
  121. </view>
  122. <!-- 商品列表 -->
  123. <block v-if="data.length > 0">
  124. <block v-for="(item, index) in data" :key="index">
  125. <component-goods-list :propData="item" propMoreUrlKey="more_url" :propKeywordsUrl="'/pages/plugins/shop/search/search?shop_id='+shop.id+'&keywords='" :propIsAutoPlay="true" :propCurrencySymbol="currency_symbol"></component-goods-list>
  126. </block>
  127. </block>
  128. </view>
  129. </block>
  130. <block v-else>
  131. <component-no-data propStatus="0"></component-no-data>
  132. </block>
  133. </block>
  134. <!-- 拖拽模式 -->
  135. <block v-if="(shop.data_model || 0) == 2">
  136. <block v-if="(data || null) != null && data.length > 0">
  137. <!-- 拖拽模式、引入拖拽数据模块 -->
  138. <component-layout :propData="data"></component-layout>
  139. </block>
  140. <block v-else>
  141. <component-no-data propStatus="0"></component-no-data>
  142. </block>
  143. </block>
  144. <!-- 结尾 -->
  145. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  146. </view>
  147. <view v-else>
  148. <!-- 提示信息 -->
  149. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  150. </view>
  151. </view>
  152. </template>
  153. <script>
  154. const app = getApp();
  155. import componentLayout from "../../../../components/layout/layout";
  156. import componentNoData from "../../../../components/no-data/no-data";
  157. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  158. import componentBanner from "../../../../components/slider/slider";
  159. import componentGoodsList from "../../../../components/goods-list/goods-list";
  160. var common_static_url = app.globalData.get_static_url('common');
  161. export default {
  162. data() {
  163. return {
  164. common_static_url: common_static_url,
  165. data_bottom_line_status: false,
  166. data_list_loding_status: 1,
  167. data_list_loding_msg: '',
  168. currency_symbol: app.globalData.data.currency_symbol,
  169. is_shop_whole_search: app.globalData.data.is_shop_whole_search || 0,
  170. params: null,
  171. user: null,
  172. data_base: null,
  173. shop: null,
  174. shop_favor_user: [],
  175. shop_navigation: [],
  176. shop_goods_category: [],
  177. slider: [],
  178. data: [],
  179. search_keywords_value: '',
  180. header_service_status: false,
  181. nav_category_status: false,
  182. shop_favor_info: {
  183. "text": "收藏",
  184. "status": 0,
  185. "count": 0
  186. },
  187. // 自定义分享信息
  188. share_info: {}
  189. };
  190. },
  191. components: {
  192. componentLayout,
  193. componentNoData,
  194. componentBottomLine,
  195. componentBanner,
  196. componentGoodsList
  197. },
  198. props: {},
  199. onLoad(params) {
  200. this.setData({
  201. params: params,
  202. user: app.globalData.get_user_cache_info()
  203. });
  204. },
  205. onShow() {
  206. this.get_data();
  207. // 初始化配置
  208. this.init_config();
  209. },
  210. // 下拉刷新
  211. onPullDownRefresh() {
  212. this.get_data();
  213. },
  214. methods: {
  215. // 初始化配置
  216. init_config(status) {
  217. if ((status || false) == true) {
  218. this.setData({
  219. currency_symbol: app.globalData.get_config('currency_symbol')
  220. });
  221. } else {
  222. app.globalData.is_config(this, 'init_config');
  223. }
  224. },
  225. // 获取数据
  226. get_data() {
  227. uni.request({
  228. url: app.globalData.get_request_url("detail", "index", "shop"),
  229. method: 'POST',
  230. data: {
  231. "id": this.params.id || 0
  232. },
  233. dataType: 'json',
  234. success: res => {
  235. uni.stopPullDownRefresh();
  236. if (res.data.code == 0) {
  237. var data = res.data.data;
  238. var temp_data = data.data || [];
  239. this.setData({
  240. data_base: data.base || null,
  241. shop: data.shop || null,
  242. shop_favor_user: data.shop_favor_user || [],
  243. shop_navigation: data.shop_navigation || [],
  244. shop_goods_category: data.shop_goods_category || [],
  245. data: temp_data,
  246. slider: data.slider || [],
  247. data_list_loding_msg: '',
  248. data_list_loding_status: 0,
  249. data_bottom_line_status: temp_data.length > 0
  250. });
  251. if ((this.shop || null) != null) {
  252. // 收藏信息
  253. var status = this.shop_favor_user.indexOf(this.shop.id) != -1 ? 1 : 0;
  254. this.setData({
  255. shop_favor_info: {
  256. "count": this.shop.shop_favor_count || 0,
  257. "status": status,
  258. "text": (status == 1 ? '已' : '') + '收藏'
  259. }
  260. });
  261. // 基础自定义分享
  262. this.setData({
  263. share_info: {
  264. title: this.shop.seo_title || this.shop.name,
  265. desc: this.shop.seo_desc || this.shop.describe,
  266. path: '/pages/plugins/shop/detail/detail',
  267. query: 'id='+this.shop.id,
  268. img: this.shop.logo
  269. }
  270. });
  271. // 标题名称
  272. uni.setNavigationBarTitle({
  273. title: this.shop.name
  274. });
  275. }
  276. } else {
  277. this.setData({
  278. data_bottom_line_status: false,
  279. data_list_loding_status: 2,
  280. data_list_loding_msg: res.data.msg
  281. });
  282. }
  283. // 分享菜单处理
  284. app.globalData.page_share_handle(this.share_info);
  285. },
  286. fail: () => {
  287. uni.stopPullDownRefresh();
  288. this.setData({
  289. data_bottom_line_status: false,
  290. data_list_loding_status: 2,
  291. data_list_loding_msg: '服务器请求出错'
  292. });
  293. app.globalData.showToast('服务器请求出错');
  294. }
  295. });
  296. },
  297. // 店铺收藏事件
  298. shop_favor_event(e) {
  299. var user = app.globalData.get_user_info(this, 'shop_favor_event');
  300. if (user != false) {
  301. // 用户未绑定用户则转到登录页面
  302. if (app.globalData.user_is_need_login(user)) {
  303. uni.navigateTo({
  304. url: "/pages/login/login?event_callback=shop_favor_event"
  305. });
  306. return false;
  307. } else {
  308. uni.showLoading({
  309. title: '处理中...'
  310. });
  311. uni.request({
  312. url: app.globalData.get_request_url("favor", "shopfavor", "shop"),
  313. method: 'POST',
  314. data: {
  315. "id": this.shop.id
  316. },
  317. dataType: 'json',
  318. success: res => {
  319. uni.hideLoading();
  320. if (res.data.code == 0) {
  321. this.setData({
  322. shop_favor_info: res.data.data
  323. });
  324. app.globalData.showToast(res.data.msg, 'success');
  325. } else {
  326. if (app.globalData.is_login_check(res.data, this, 'shop_favor_event')) {
  327. app.globalData.showToast(res.data.msg);
  328. }
  329. }
  330. },
  331. fail: () => {
  332. uni.hideLoading();
  333. app.globalData.showToast('服务器请求出错');
  334. }
  335. });
  336. }
  337. }
  338. },
  339. // 搜索输入事件
  340. search_keywords_event(e) {
  341. this.setData({
  342. search_keywords_value: e.detail.value || ''
  343. });
  344. },
  345. // 搜索事件
  346. search_button_event(e) {
  347. var value = e.currentTarget.dataset.value || null;
  348. uni.navigateTo({
  349. url: value + 'keywords=' + this.search_keywords_value || ''
  350. });
  351. },
  352. // 导航分类事件
  353. header_service_event(e) {
  354. this.setData({
  355. header_service_status: !this.header_service_status
  356. });
  357. },
  358. // 导航分类事件
  359. nav_shop_category_event(e) {
  360. this.setData({
  361. nav_category_status: !this.nav_category_status
  362. });
  363. },
  364. // 导航分类事件
  365. shop_category_event(e) {
  366. var value = e.currentTarget.dataset.value || null;
  367. uni.navigateTo({
  368. url: '/pages/plugins/shop/search/search?shop_id=' + this.shop.id + '&category_id=' + value
  369. });
  370. },
  371. // 导航事件
  372. nav_event(e) {
  373. app.globalData.url_event(e);
  374. },
  375. // url事件
  376. url_event(e) {
  377. app.globalData.url_event(e);
  378. },
  379. // 剪切板
  380. text_copy_event(e) {
  381. app.globalData.text_copy_event(e);
  382. },
  383. // 电话
  384. tel_event(e) {
  385. app.globalData.call_tel(e.currentTarget.dataset.value || null);
  386. },
  387. // 图片预览
  388. image_show_event(e) {
  389. app.globalData.image_show_event(e);
  390. },
  391. // 进入客服系统
  392. chat_event() {
  393. app.globalData.chat_entry_handle(this.shop.chat_info.chat_url);
  394. }
  395. }
  396. };
  397. </script>
  398. <style>
  399. @import './detail.css';
  400. </style>