realstore-list.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view>
  3. <view v-if="(data_list || null) != null && data_list.length > 0" class="plugins-realstore-data-list oh">
  4. <block v-for="(item, index) in data_list" :key="index">
  5. <view class="item bg-white padding-main border-radius-main pr spacing-mb" :data-value="item.url" @tap="url_event">
  6. <view class="base oh">
  7. <!-- 基础内容 -->
  8. <image :src="item.logo" mode="widthFix" class="logo circle fl br"></image>
  9. <view class="base-right fr">
  10. <view :class="'status-icon pa text-size-xs '+((item.status_info.status == 1) ? 'bg-main cr-white' : 'bg-gray cr-gray')">{{item.status_info.msg}}</view>
  11. <view class="title fw-b text-size single-text">
  12. <text v-if="(item.alias || null) != null" class="va-m title-icon round br-main cr-main text-size-xs padding-left-sm padding-right-sm margin-right-xs">{{item.alias}}</text>
  13. <text class="va-m">{{item.name}}</text>
  14. </view>
  15. <view class="margin-top-xs text-size-xs cr-grey">
  16. <view v-if="(item.status_info.time || null) != null">营业时间:{{item.status_info.time}}</view>
  17. <view v-if="(item.distance || null) != null">距离您{{item.distance}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 地址 -->
  22. <view class="margin-top-sm oh cp">
  23. <view class="dis-inline-block va-m">
  24. <uni-icons type="location-filled" size="32rpx" color="#8d8d8d"></uni-icons>
  25. </view>
  26. <view class="address-content single-text cr-base margin-left-xs dis-inline-block text-size-xs va-m" :data-value="item.province_name+item.city_name+item.county_name+item.address" @tap.stop="text_copy_event">{{item.province_name}}{{item.city_name}}{{item.county_name}}{{item.address}}</view>
  27. </view>
  28. <!-- 右侧操作 -->
  29. <view class="icon-list pa">
  30. <!-- #ifndef MP-KUAISHOU -->
  31. <view v-if="(item.lat != 0 && item.lng != 0)" class="icon-item bg-green circle dis-inline-block tc cp" :data-index="index" @tap.stop="address_map_event">
  32. <uni-icons type="paperplane-filled" size="32rpx" color="#fff"></uni-icons>
  33. </view>
  34. <!-- #endif -->
  35. <view v-if="(item.service_tel || null) != null" class="icon-item bg-yellow circle dis-inline-block tc cp" :data-value="item.service_tel" @tap.stop="tel_event">
  36. <uni-icons type="phone-filled" size="32rpx" color="#fff"></uni-icons>
  37. </view>
  38. <view v-if="propIsFavor" :class="'icon-item circle dis-inline-block tc cp pr '+((item.is_favor || 0) == 1 ? 'bg-red' : 'bg-gray')" :data-index="index" @tap.stop="favor_event">
  39. <uni-icons type="heart-filled" size="32rpx" color="#fff"></uni-icons>
  40. </view>
  41. </view>
  42. </view>
  43. </block>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. const app = getApp();
  49. export default {
  50. data() {
  51. return {
  52. data_list: [],
  53. favor_user: []
  54. };
  55. },
  56. components: {},
  57. props: {
  58. propIsFavor: {
  59. type: Boolean,
  60. default: true
  61. },
  62. propDataList: {
  63. type: Array,
  64. default: () => []
  65. },
  66. propFavorUser: {
  67. type: Array,
  68. default: () => []
  69. }
  70. },
  71. // 属性值改变监听
  72. watch: {
  73. // 数据列表
  74. propDataList(value, old_value) {
  75. this.setData({
  76. data_list: value
  77. });
  78. this.data_list_handle();
  79. }
  80. },
  81. // 页面被展示
  82. created: function(e) {
  83. this.setData({
  84. data_list: this.propDataList,
  85. favor_user: this.propFavorUser
  86. });
  87. this.data_list_handle();
  88. },
  89. methods: {
  90. // 数据列表处理
  91. data_list_handle() {
  92. var temp_data_list = this.data_list;
  93. for(var i in temp_data_list) {
  94. temp_data_list[i]['is_favor'] = (this.favor_user.indexOf(temp_data_list[i]['id']) == -1) ? 0 : 1;
  95. }
  96. this.setData({
  97. data_list: temp_data_list
  98. });
  99. },
  100. // 收藏事件
  101. favor_event(e) {
  102. if(!app.globalData.is_single_page_check()) {
  103. return false;
  104. }
  105. var user = app.globalData.get_user_info(this, 'favor_event');
  106. if (user != false) {
  107. // 用户未绑定用户则转到登录页面
  108. if (app.globalData.user_is_need_login(user)) {
  109. uni.navigateTo({
  110. url: "/pages/login/login?event_callback=favor_event"
  111. });
  112. return false;
  113. } else {
  114. var index = e.currentTarget.dataset.index;
  115. var info = this.data_list[index];
  116. uni.showLoading({
  117. title: '处理中...'
  118. });
  119. uni.request({
  120. url: app.globalData.get_request_url("reversal", "favor", "realstore"),
  121. method: 'POST',
  122. data: {
  123. "id": info.id
  124. },
  125. dataType: 'json',
  126. success: res => {
  127. uni.hideLoading();
  128. if (res.data.code == 0) {
  129. var temp_data = this.data_list;
  130. var temp_favor = this.favor_user;
  131. temp_data[index]['is_favor'] = res.data.data.status;
  132. if(res.data.data.status == 1) {
  133. if(temp_favor.indexOf(info.id) == -1) {
  134. temp_favor.push(info.id);
  135. }
  136. } else {
  137. if(temp_favor.indexOf(info.id) != -1) {
  138. temp_favor.splice(index, 1);
  139. }
  140. }
  141. this.setData({
  142. data_list: temp_data,
  143. favor_user: temp_favor
  144. });
  145. app.globalData.showToast(res.data.msg, "success");
  146. } else {
  147. if (app.globalData.is_login_check(res.data, this, 'favor_event')) {
  148. app.globalData.showToast(res.data.msg);
  149. }
  150. }
  151. },
  152. fail: () => {
  153. uni.hideLoading();
  154. app.globalData.showToast('服务器请求出错');
  155. }
  156. });
  157. }
  158. }
  159. },
  160. // 剪切板
  161. text_copy_event(e) {
  162. app.globalData.text_copy_event(e);
  163. },
  164. // 地图查看
  165. address_map_event(e) {
  166. var info = this.data_list[e.currentTarget.dataset.index];
  167. if (info.lat == 0 || info.lng == 0) {
  168. app.globalData.showToast("地址有误");
  169. return false;
  170. }
  171. // 打开地图
  172. var address = (info.province_name || '') + (info.city_name || '') + (info.county_name || '') + (info.address || '');
  173. app.globalData.open_location(info.lng, info.lat, info.name, address);
  174. },
  175. // 电话
  176. tel_event(e) {
  177. app.globalData.call_tel(e.currentTarget.dataset.value || null);
  178. },
  179. // url事件
  180. url_event(e) {
  181. app.globalData.url_event(e);
  182. }
  183. }
  184. };
  185. </script>
  186. <style>
  187. </style>