sale.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class="center">
  3. <view class="product" v-for="(item, index) in productList">
  4. <view class="product-top flex">
  5. <image class="product-image" :src="item.image" mode=""></image>
  6. <view class="product-info">
  7. <view class="title">{{ item.store_name }}</view>
  8. <view class="title buyId">x{{ item.num }}</view>
  9. <view class="title buyName">¥{{ item.price * 1 * item.num }}</view>
  10. </view>
  11. <view class="kc">
  12. 库存:
  13. <text>{{ item.number }}</text>
  14. </view>
  15. </view>
  16. <view class="product-bottom flex">
  17. <view class="product-bottom-left">购买数量</view>
  18. <view class="product-bottom-right">
  19. <uni-number-box class="step" :isMin="true" :value="num" :min="0" :max="item.number" @eventChange="numberChange(item, arguments)"></uni-number-box>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="top-search flex">
  24. <view class="search-box flex" @click="clickSearch()">
  25. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  26. <view class="search-font"><input type="text" placeholder="输入手机号或id或昵称搜索" v-model="productname" /></view>
  27. </view>
  28. </view>
  29. <scroll-view scroll-y="true" class="list-scroll-content" :style="{ height: height }" @scrolltolower="getuser">
  30. <view class="type-item flex" v-for="(item, index) in userList" @click="changePayType(item.uid)">
  31. <view class="type-item-left">
  32. <view class="type-item-avater"><image :src="item.avatar" mode=""></image></view>
  33. <view class="type-item-info">
  34. <view class="type-item-name">{{ item.nickname }}</view>
  35. <view class="type-item-phone">{{ item.phone }}</view>
  36. </view>
  37. </view>
  38. <label class="radio"><radio value="" color="#d8a668" :checked="type == item.uid"></radio></label>
  39. </view>
  40. </scroll-view>
  41. <view class="bottom-box"><view class="bottom-item1" @click="sale()">确认出货</view></view>
  42. </view>
  43. </template>
  44. <script>
  45. import uniCopy from '@/components/js_sdk/xb-copy/uni-copy.js';
  46. import { user_product } from '@/api/user.js';
  47. import { deliver_goods } from '@/api/product.js';
  48. import { upload, user_list } from '@/api/order.js';
  49. import uniNumberBox from '@/components/uni-number-box.vue';
  50. import { timeComputed } from '@/utils/rocessor.js';
  51. export default {
  52. components: {
  53. uniNumberBox
  54. },
  55. onReady(res) {
  56. var _this = this;
  57. uni.getSystemInfo({
  58. success: resu => {
  59. const query = uni.createSelectorQuery();
  60. query.select('.list-scroll-content').boundingClientRect();
  61. query.exec(function(res) {
  62. _this.height = resu.windowHeight - res[0].top + 'px';
  63. console.log('打印页面的剩余高度', _this.height);
  64. });
  65. },
  66. fail: res => {}
  67. });
  68. },
  69. data() {
  70. return {
  71. num: 0,
  72. productList: [],
  73. buyList: {},
  74. userList: [],
  75. pages: 1,
  76. limit: 10,
  77. loadType: 'more',
  78. height: '',
  79. productname: '',
  80. type: '',
  81. info: ''
  82. };
  83. },
  84. onLoad(option) {
  85. this.getuser();
  86. this.loadData();
  87. if (option.type) {
  88. this.type = option.type;
  89. }
  90. },
  91. methods: {
  92. uploads() {
  93. upload({
  94. filename: ''
  95. }).then(data => {
  96. this.image = data[0].url;
  97. console.log(this.image);
  98. });
  99. },
  100. clickSearch() {
  101. this.pages = 1;
  102. this.limit = 10;
  103. this.loadType = 'more';
  104. this.userList = [];
  105. this.getuser();
  106. },
  107. getuser() {
  108. const obj = this;
  109. if (obj.loadType == 'nomore' || obj.loadType == 'loading') {
  110. return;
  111. }
  112. obj.loadType = 'loading';
  113. user_list({ pages: obj.pages, limit: obj.limit, name: obj.productname }).then(({ data }) => {
  114. obj.userList = obj.userList.concat(data.user);
  115. if (data.user.length != obj.limit) {
  116. obj.loadType = 'nomore';
  117. } else {
  118. obj.loadType = 'more';
  119. }
  120. });
  121. },
  122. loadData() {
  123. user_product({ pages: 1, limit: 1000 }).then(({ data }) => {
  124. data.list.forEach(e => {
  125. e.num = 0;
  126. console.log(e, '123456');
  127. });
  128. this.productList = data.list;
  129. });
  130. },
  131. nav(url) {
  132. uni.navigateTo({
  133. url
  134. });
  135. },
  136. sale() {
  137. const obj = this;
  138. if (obj.buyList === {}) {
  139. return obj.$api.msg('请选择出货商品');
  140. }
  141. if (obj.image == '') {
  142. return obj.$api.msg('请选择出货人');
  143. }
  144. deliver_goods({ uid: obj.type, product_id: this.buyList }).then(e => {
  145. uni.navigateTo({
  146. url: '/pages/shop/sucess'
  147. });
  148. });
  149. },
  150. changePayType(e) {
  151. this.type = e;
  152. },
  153. copy(value) {
  154. let obj = this;
  155. let content = value; //需要复制的内容
  156. console.log('复制的内容:', content);
  157. // content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
  158. const result = uniCopy(content);
  159. if (result === false) {
  160. uni.showToast({
  161. title: '不支持'
  162. });
  163. } else {
  164. uni.showToast({
  165. title: '复制成功',
  166. icon: 'none'
  167. });
  168. }
  169. },
  170. // 查看大图
  171. lookimg(src) {
  172. console.log(src);
  173. let arr = [src];
  174. uni.previewImage({
  175. current: src,
  176. urls: arr
  177. });
  178. },
  179. //swiper 切换
  180. changeTab(e) {
  181. this.tabCurrentIndex = e.target.current;
  182. },
  183. toBack() {
  184. uni.navigateBack({});
  185. },
  186. change(num) {
  187. this.tabCurrentIndex = num * 1;
  188. },
  189. // 购买数量变化
  190. numberChange(e, num) {
  191. const obj = this;
  192. obj.buyList[e.id] = num[0].number;
  193. e.num = num[0].number;
  194. if (num[0].number == 0) {
  195. Reflect.deleteProperty(obj.buyList, e.id);
  196. }
  197. console.log(obj.buyList);
  198. }
  199. }
  200. };
  201. </script>
  202. <style lang="less">
  203. .center {
  204. background: #f8f6f6;
  205. min-height: 100%;
  206. height: auto;
  207. }
  208. .product-top {
  209. position: relative;
  210. margin-top: 20rpx;
  211. padding: 35rpx 35rpx 40rpx 35rpx;
  212. background-color: #ffffff;
  213. justify-content: flex-start;
  214. align-items: flex-start;
  215. border-bottom: 1px solid #eeeeee;
  216. .kc {
  217. position: absolute;
  218. bottom: 20rpx;
  219. right: 20rpx;
  220. font-size: 26rpx;
  221. font-weight: 500;
  222. color: #999999;
  223. text {
  224. color: #fd3b39;
  225. }
  226. }
  227. .product-image {
  228. width: 210rpx;
  229. height: 210rpx;
  230. border-radius: 10rpx;
  231. }
  232. .product-info {
  233. margin-left: 26rpx;
  234. padding-top: 10rpx;
  235. line-height: 1;
  236. .title {
  237. font-size: 35rpx;
  238. font-family: PingFang SC;
  239. font-weight: bold;
  240. color: #333333;
  241. }
  242. .buyId {
  243. font-size: 26rpx;
  244. font-weight: 500;
  245. color: #999999;
  246. margin-top: 30rpx;
  247. }
  248. .buyName {
  249. margin-top: 82rpx;
  250. color: #fd3b39;
  251. }
  252. }
  253. }
  254. .product-bottom {
  255. padding: 30rpx 24rpx 24rpx;
  256. background: #ffffff;
  257. .product-bottom-left {
  258. font-size: 28rpx;
  259. font-family: PingFang SC;
  260. font-weight: 500;
  261. color: #333333;
  262. }
  263. }
  264. .top-search {
  265. margin-top: 20rpx;
  266. height: 80rpx;
  267. padding: 0 20rpx;
  268. background-color: #f8f6f6;
  269. .search-box {
  270. justify-content: center;
  271. width: 698rpx;
  272. height: 66rpx;
  273. background: #fff;
  274. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  275. border-radius: 30rpx;
  276. .search {
  277. width: 34rpx;
  278. height: 34rpx;
  279. }
  280. .search-font {
  281. width: 500rpx;
  282. margin-left: 14rpx;
  283. font-size: 28rpx;
  284. font-family: PingFang SC;
  285. font-weight: 500;
  286. color: #cbcbcb;
  287. }
  288. }
  289. }
  290. .list-scroll-content {
  291. padding-bottom: 100rpx;
  292. background: #fff;
  293. .type-item {
  294. padding: 30rpx 24rpx 20rpx;
  295. border-bottom: 1px solid #f0f0f0;
  296. .type-item-left {
  297. display: flex;
  298. align-items: center;
  299. .type-item-avater {
  300. width: 80rpx;
  301. height: 80rpx;
  302. border-radius: 50%;
  303. image {
  304. width: 100%;
  305. height: 100%;
  306. border-radius: 50%;
  307. }
  308. }
  309. .type-item-info {
  310. margin-left: 20rpx;
  311. .type-item-name {
  312. font-size: 30rpx;
  313. font-family: PingFangSC;
  314. font-weight: 500;
  315. color: #3f454b;
  316. }
  317. .type-item-phone {
  318. margin-top: 20rpx;
  319. font-size: 22rpx;
  320. font-family: PingFang SC;
  321. font-weight: 400;
  322. color: #999999;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. .bottom-box {
  329. width: 750rpx;
  330. height: 200rpx;
  331. background: linear-gradient(0deg, #ffffff, rgba(255, 255, 255, 0));
  332. padding: 68rpx 38rpx 0;
  333. display: flex;
  334. justify-content: space-between;
  335. .bottom-item1 {
  336. width: 674rpx;
  337. height: 88rpx;
  338. background: #ecd0a9;
  339. border-radius: 44rpx;
  340. font-size: 36rpx;
  341. text-align: center;
  342. font-family: PingFang SC;
  343. font-weight: 500;
  344. color: #54320b;
  345. line-height: 88rpx;
  346. }
  347. }
  348. </style>