index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <view class="record">
  3. <!-- #ifdef H5 -->
  4. <view class="top_nav acea-row row-around">
  5. <text :class="active == 0 ? 'on' : ''" @click="switchTab(0)">购买记录</text>
  6. <text :class="active == 1 ? 'on' : ''" @click="switchTab(1)">浏览记录</text>
  7. </view>
  8. <view class="search acea-row row-center row-middle">
  9. <input type="text" v-model="keywords" class="search_input" placeholder="搜索商品" placeholder-class="text_gray"
  10. @blur="search()">
  11. </view>
  12. <Loading :loaded="loaded" :loading="loading"></Loading>
  13. <view class="goods_list" v-if="goodsList.length">
  14. <view class="item acea-row" v-for="(item,index) in goodsList" :key="index">
  15. <view class="picture">
  16. <image :src="item.image" mode="aspectFit"></image>
  17. </view>
  18. <view class="goods_info acea-row row-column row-between">
  19. <view class="name line2">{{item.store_name}}</view>
  20. <view class="stork acea-row row-between">
  21. <text>库存 {{item.stock}}</text>
  22. <text>销量 {{item.sales}}</text>
  23. <text class="pushFn" @click="pushFn(item)">推送</text>
  24. </view>
  25. </view>
  26. <view class="price_info acea-row row-column row-between">
  27. <text class="price">¥{{item.price}}</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="empty-box" v-else>
  32. <image src="../../users/static/shop_record.png" v-if="active == 0"></image>
  33. <image src="../../users/static/view_record.png" v-if="active == 1"></image>
  34. <view>暂无 {{active ? '浏览' : '购买'}}记录</view>
  35. </view>
  36. <view class="ht100"></view>
  37. <tNav :active="2"></tNav>
  38. <!-- #endif -->
  39. </view>
  40. </template>
  41. <script>
  42. // #ifdef H5
  43. import tNav from '../components/tabNav.vue';
  44. import Loading from '@/components/Loading/index.vue';
  45. import {
  46. initWxConfig,
  47. initAgentConfig,
  48. } from "@/libs/work.js";
  49. import {
  50. getWorkCartList,
  51. getWorkVisitInfo,
  52. getWorkAgentConfig
  53. } from "@/api/work.js"
  54. // import {
  55. // wx
  56. // } from "@/utils/agent.js"
  57. export default {
  58. data() {
  59. return {
  60. keywords: "",
  61. userId: "",
  62. loaded: false,
  63. loading: false, //是否加载中
  64. loadend: false, //是否加载完毕
  65. loadTitle: '加载更多', //提示语
  66. goodsList: [], //商品数组
  67. active: 0, //选项状态
  68. page: 1,
  69. limit: 10,
  70. }
  71. },
  72. components: {
  73. Loading,
  74. tNav
  75. },
  76. onLoad() {
  77. this.userId = this.$Cache.get('work_user_id')
  78. this.getList();
  79. },
  80. methods: {
  81. // 推送到商品详情
  82. pushFn(item) {
  83. getWorkAgentConfig(location.href).then(res => {
  84. jWeixin.agentConfig({
  85. corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
  86. agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
  87. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  88. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  89. signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
  90. jsApiList: ["getCurExternalContact", "getCurExternalChat", "getContext", "chooseImage", "sendChatMessage", ],
  91. success: function(res) {
  92. console.log(res)
  93. },
  94. });
  95. jWeixin.invoke('sendChatMessage', {
  96. msgtype: "news", //消息类型,必填
  97. enterChat: true, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
  98. news: {
  99. link: "https://test.pro.wuht.net/pages/goods_details/index?id=" + item.id, //H5消息页面url 必填
  100. title: item.store_name, //H5消息标题
  101. desc: "", //H5消息摘要
  102. imgUrl: item.image, //H5消息封面图片URL
  103. },
  104. }, function(res) {
  105. if (res.err_msg == 'sendChatMessage:ok') {
  106. console.log('发送成功', res)
  107. //发送成功
  108. } else {
  109. //发送失败
  110. console.log('发送失败', res)
  111. }
  112. })
  113. })
  114. },
  115. switchTab(index) {
  116. if (this.loading) return
  117. if (index === this.active) return;
  118. this.active = index;
  119. this.loadend = false;
  120. this.page = 1;
  121. this.$set(this, 'goodsList', []);
  122. this.getList();
  123. },
  124. search() {
  125. if (this.loading) return
  126. this.loadend = false;
  127. this.page = 1;
  128. this.$set(this, 'goodsList', []);
  129. this.getList();
  130. },
  131. getList() {
  132. let that = this;
  133. let params = {};
  134. if (that.loadend) return;
  135. if (that.loading) return;
  136. that.loading = true;
  137. that.loadTitle = '加载更多';
  138. params = {
  139. userid: that.userId,
  140. store_name: that.keywords,
  141. page: that.page,
  142. limit: that.limit,
  143. }
  144. if (that.active == 0) {
  145. getWorkCartList(params).then(res => {
  146. let list = res.data || [];
  147. let loadend = list.length < that.limit;
  148. that.goodsList = that.$util.SplitArray(list, that.goodsList);
  149. that.$set(that, 'goodsList', that.goodsList);
  150. that.loadend = loadend;
  151. that.loading = false;
  152. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  153. that.page = that.page + 1;
  154. }).catch(err => {
  155. return that.$util.Tips({
  156. title: err
  157. });
  158. })
  159. } else if (that.active == 1) {
  160. getWorkVisitInfo(params).then(res => {
  161. let list = res.data || [];
  162. let loadend = list.length < that.limit;
  163. that.goodsList = that.$util.SplitArray(list, that.goodsList);
  164. that.$set(that, 'goodsList', that.goodsList);
  165. that.loadend = loadend;
  166. that.loading = false;
  167. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  168. that.page = that.page + 1;
  169. }).catch(err => {
  170. return that.$util.Tips({
  171. title: err
  172. });
  173. })
  174. }
  175. }
  176. },
  177. onReachBottom: function() {
  178. this.getList();
  179. }
  180. }
  181. // #endif
  182. </script>
  183. <style lang="scss">
  184. /* #ifdef H5 */
  185. .top_nav {
  186. height: 80rpx;
  187. line-height: 80rpx;
  188. background: #FFFFFF;
  189. font-size: 28rpx;
  190. font-family: PingFangSC-Regular, PingFang SC;
  191. font-weight: 400;
  192. color: #000000;
  193. .on {
  194. font-size: 28rpx;
  195. font-family: PingFangSC-Semibold, PingFang SC;
  196. font-weight: 600;
  197. color: #1890FF;
  198. }
  199. }
  200. .search {
  201. border-top: 1px solid #f5f5f5;
  202. height: 100rpx;
  203. background: #FFFFFF;
  204. .search_input {
  205. width: 690rpx;
  206. height: 60rpx;
  207. background: #F5F6F9;
  208. border-radius: 34rpx;
  209. padding-left: 20rpx;
  210. }
  211. }
  212. .text_gray {
  213. font-size: 28rpx;
  214. font-family: PingFangSC-Regular, PingFang SC;
  215. font-weight: 400;
  216. color: #CCCCCC;
  217. text-align: center;
  218. }
  219. .goods_list {
  220. .item {
  221. position: relative;
  222. width: 710rpx;
  223. height: 192rpx;
  224. border-radius: 12rpx;
  225. margin: 20rpx auto 0;
  226. padding: 26rpx 24rpx 26rpx;
  227. box-sizing: border-box;
  228. background: #FFFFFF;
  229. .pushFn {
  230. position: absolute;
  231. bottom: 28rpx;
  232. right: 24rpx;
  233. width: 112rpx;
  234. height: 52rpx;
  235. border-radius: 28rpx;
  236. border: 2rpx solid #1890FF;
  237. font-size: 26rpx;
  238. font-weight: 400;
  239. line-height: 52rpx;
  240. text-align: center;
  241. color: #1890FF;
  242. }
  243. .picture {
  244. width: 140rpx;
  245. height: 140rpx;
  246. border-radius: 8rpx;
  247. image {
  248. width: 100%;
  249. height: 100%;
  250. }
  251. }
  252. .goods_info {
  253. width: 280rpx;
  254. margin-left: 22rpx;
  255. .name {
  256. height: 80rpx;
  257. line-height: 40rpx;
  258. font-size: 28rpx;
  259. color: rgba(0, 0, 0, 0.85);
  260. }
  261. .stork {
  262. font-size: 24rpx;
  263. font-weight: 400;
  264. color: #666666;
  265. }
  266. }
  267. .price_info {
  268. margin-left: 80rpx;
  269. .price {
  270. font-size: 28rpx;
  271. font-weight: 500;
  272. color: #E93323;
  273. }
  274. .send_btn {
  275. width: 112rpx;
  276. height: 52rpx;
  277. display: inline-block;
  278. margin-left: 20rpx;
  279. line-height: 52rpx;
  280. text-align: center;
  281. border-radius: 28rpx;
  282. border: 1px solid #1890FF;
  283. font-size: 26rpx;
  284. font-weight: 400;
  285. color: #1890FF;
  286. }
  287. }
  288. }
  289. }
  290. .empty-box {
  291. height: 600rpx;
  292. display: flex;
  293. flex-direction: column;
  294. justify-content: center;
  295. align-items: center;
  296. image {
  297. width: 390rpx;
  298. height: 264rpx;
  299. }
  300. }
  301. .ht100 {
  302. height: 120rpx;
  303. }
  304. /* #endif */
  305. </style>