index.vue 11 KB

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