李浩杰 4 rokov pred
rodič
commit
aff73ccfb2
50 zmenil súbory, kde vykonal 1465 pridanie a 40 odobranie
  1. 4 1
      app/Http/Controllers/Admin/TestController.php
  2. 5 0
      app/Http/Controllers/Api/mini/AuthController.php
  3. 4 0
      app/Http/Controllers/Api/mini/BaseController.php
  4. 21 0
      app/Http/Controllers/Api/mini/DeviceController.php
  5. 74 0
      app/Http/Controllers/Api/mini/OrderController.php
  6. 0 2
      app/Http/Controllers/Api/mini/ProjectController.php
  7. 27 0
      app/Http/Controllers/Api/mini/WorkPointController.php
  8. 2 2
      app/Models/BaseModel.php
  9. 8 0
      app/Models/Device.php
  10. 28 0
      app/Models/Option.php
  11. 27 0
      app/Models/Order.php
  12. 11 0
      app/Models/OrderDevice.php
  13. 8 0
      app/Models/WorkPoint.php
  14. 1 1
      database/migrations/2020_12_03_130931_create_users_table.php
  15. 32 0
      database/migrations/2020_12_10_013450_create_work_points_table.php
  16. 34 0
      database/migrations/2020_12_10_013627_create_orders_table.php
  17. 33 0
      database/migrations/2020_12_10_013716_create_devices_table.php
  18. 35 0
      database/migrations/2020_12_10_013730_create_order_devices_table.php
  19. 30 0
      database/migrations/2020_12_10_020009_add_name_to_order_device.php
  20. 33 0
      database/migrations/2020_12_10_031901_add_admin_user_id_to_orders.php
  21. 30 0
      database/migrations/2020_12_10_081251_add_is_draft_to_orders.php
  22. 36 0
      database/migrations/2020_12_10_081639_create_options_table.php
  23. 30 0
      database/migrations/2020_12_10_130450_add_color_to_options.php
  24. 30 0
      database/migrations/2020_12_10_131931_add_level_to_project_role.php
  25. 30 0
      database/migrations/2020_12_10_132121_add_project_role_id_to_orders.php
  26. 31 0
      database/migrations/2020_12_10_143957_add_last_project_role_id_to_orders.php
  27. 8 0
      database/seeds/DatabaseSeeder.php
  28. 22 0
      database/seeds/DeviceSeeder.php
  29. 121 0
      database/seeds/MiniSeeder.php
  30. 36 0
      database/seeds/OptionSeeder.php
  31. 3 1
      database/seeds/ProjectRoleSeeder.php
  32. 20 0
      database/seeds/WorkPointSeeder.php
  33. 23 21
      mini/app.js
  34. 5 2
      mini/app.json
  35. 41 0
      mini/app.wxss
  36. 176 0
      mini/pages/create-order/index.js
  37. 4 0
      mini/pages/create-order/index.json
  38. 83 0
      mini/pages/create-order/index.wxml
  39. 43 0
      mini/pages/create-order/index.wxss
  40. 3 0
      mini/pages/login/index.wxss
  41. 129 0
      mini/pages/order/index.js
  42. 3 0
      mini/pages/order/index.json
  43. 50 0
      mini/pages/order/index.wxml
  44. 21 0
      mini/pages/order/index.wxss
  45. 8 2
      mini/pages/project/index.js
  46. 11 7
      mini/pages/project/index.wxml
  47. 42 0
      mini/utils/api.js
  48. 1 1
      mini/utils/util.js
  49. BIN
      public/mini/default-user.png
  50. 8 0
      routes/api.php

+ 4 - 1
app/Http/Controllers/Admin/TestController.php

xqd xqd
@@ -2,8 +2,11 @@
 
 namespace App\Http\Controllers\Admin;
 
+use App\Models\Order;
+use App\Models\OrderDevice;
 use App\Models\ProjectUser;
 use App\Models\User;
+use Carbon\Carbon;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 
@@ -12,7 +15,7 @@ class TestController extends Controller
 {
     public function index(Request $request)
     {
-        dd(ProjectUser::first()->projectRole);
+        dd(Order::all()->random());
     	return view('admin.test.index');
     }
 }

+ 5 - 0
app/Http/Controllers/Api/mini/AuthController.php

xqd
@@ -54,4 +54,9 @@ class AuthController extends BaseController
         ]);
         return $this->success();
     }
+
+    public function getUserInfo()
+    {
+        return $this->success(['data' => Auth::guard('mini')->user()]);
+    }
 }

+ 4 - 0
app/Http/Controllers/Api/mini/BaseController.php

xqd
@@ -21,4 +21,8 @@ class BaseController extends Controller
     {
         return response()->json($data);
     }
+
+    public function transMoney($money) {
+        return round($money * 100);
+    }
 }

+ 21 - 0
app/Http/Controllers/Api/mini/DeviceController.php

xqd
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\Device;
+
+class DeviceController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new Device();
+    }
+
+    public function get()
+    {
+        $items = $this->model->get();
+        return $this->success(['data' => $items]);
+    }
+}

+ 74 - 0
app/Http/Controllers/Api/mini/OrderController.php

xqd
@@ -0,0 +1,74 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\Device;
+use App\Models\Option;
+use App\Models\Order;
+use App\Models\OrderDevice;
+use App\Models\Project;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Log;
+
+class OrderController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new Order();
+    }
+
+    public function create(Request $request)
+    {
+        $project = Project::find($request->input('project_id'));
+        if(!$project) return $this->error(['msg' => '找不到项目']);
+        $user = Auth::guard('mini')->user();
+        $order = Order::create([
+            'work_point_id' => $request->input('work_point_id'),
+            'remark' => $request->input('remark'),
+            'is_draft' => $request->input('is_draft'),
+            'status' => Option::get('orders', 'status', 'checking'),
+            'order_number' => $this->model->createOrderNumber(),
+            'project_id' => $project->id,
+            'user_id' => $user->id
+        ]);
+        if(!$order) return $this->error(['msg' => '订单创建失败']);
+        $devices = $request->input('devices');
+        $total = 0;
+        foreach($devices as $device) {
+            $price = $this->transMoney($device['price']);
+            OrderDevice::create([
+                'name' => $device['name'],
+                'order_id' => $order->id,
+                'device_id' => $device['type_id'],
+                'quantity' => $device['quantity'],
+                'price' => $price
+            ]);
+            $total = $total + ($price * (int)$device['quantity']);
+        }
+        $order->update(['money' => $total]);
+        return $this->success();
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->where('project_id', $request->input('project_id'));
+        if($request->input('status')) {
+            $status = Option::get('orders', 'status', $request->input('status'));
+            if($status) $items = $items->where('status', $status);
+        }
+        $items = $items->paginate();
+        foreach($items as $item) {
+            $item->devices = OrderDevice::where('order_id', $item->id)->get();
+            foreach($item->devices as $device) {
+                $device->type = $device->device ? $device->device->name : '';
+            }
+            $item->user_name = $item->user ? $item->user->name : '';
+            $item->status = Option::getById($item->status, 'name');
+            $item->date_time = substr($item->created_at, 0, 16);
+        }
+        return $this->success(['data' => $items->items()]);
+    }
+}

+ 0 - 2
app/Http/Controllers/Api/mini/ProjectController.php

xqd
@@ -3,10 +3,8 @@
 namespace App\Http\Controllers\Api\mini;
 
 use App\Models\Project;
-use App\Models\ProjectRole;
 use App\Models\ProjectUser;
 use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Auth;
 use Illuminate\Database\Eloquent\Builder;
 
 class ProjectController extends BaseController

+ 27 - 0
app/Http/Controllers/Api/mini/WorkPointController.php

xqd
@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\Project;
+use App\Models\ProjectRole;
+use App\Models\ProjectUser;
+use App\Models\WorkPoint;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Database\Eloquent\Builder;
+
+class WorkPointController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new WorkPoint();
+    }
+
+    public function get()
+    {
+        $items = $this->model->get();
+        return $this->success(['data' => $items]);
+    }
+}

+ 2 - 2
app/Models/BaseModel.php

xqd
@@ -65,9 +65,9 @@ class BaseModel extends Model
         return $validator;
     }
 
-    public function getOptions()
+    public static function getOptions()
     {
-        return $this->where('id', '>', 0)->orderBy('sort')->get()->toArray();
+        return self::where('id', '>', 0)->orderBy('sort')->get()->toArray();
     }
 
     public function getStatusOptions()

+ 8 - 0
app/Models/Device.php

xqd
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Models;
+
+class Device extends BaseModel
+{
+    //
+}

+ 28 - 0
app/Models/Option.php

xqd
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Models;
+
+class Option extends BaseModel
+{
+    public static function get($table, $column, $key = null, $option_key = 'id')
+    {
+        if(!$key) {
+            return self::where([
+                ['table', '=', $table],
+                ['column', '=', $column]
+            ])->orderBy('sort')->get();
+        }
+        $option = self::where([
+            ['table', '=', $table],
+            ['column', '=', $column],
+            ['key', '=', $key]
+        ])->first();
+        return $option ? $option[$option_key] : '';
+    }
+
+    public static function getById($id, $option_key = 'id')
+    {
+        $option = self::find($id);
+        return $option ? $option[$option_key] : '';
+    }
+}

+ 27 - 0
app/Models/Order.php

xqd
@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Models;
+
+use Carbon\Carbon;
+
+class Order extends BaseModel
+{
+    public static function createOrderNumber()
+    {
+        $times = 10;
+        $str = substr(Carbon::now()->format('Ymdhis'), 2);
+        do {
+            $str = $str . mt_rand(10000, 99999);
+            $res = self::where('order_number', $str)->first();
+            if(!$res) break;
+            $times = $times - 1;
+        } while($times);
+
+        return $str;
+    }
+
+    public function user()
+    {
+        return $this->belongsTo('App\Models\User', 'user_id');
+    }
+}

+ 11 - 0
app/Models/OrderDevice.php

xqd
@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+class OrderDevice extends BaseModel
+{
+    public function device()
+    {
+        return $this->belongsTo('App\Models\Device', 'device_id');
+    }
+}

+ 8 - 0
app/Models/WorkPoint.php

xqd
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Models;
+
+class WorkPoint extends BaseModel
+{
+    //
+}

+ 1 - 1
database/migrations/2020_12_03_130931_create_users_table.php

xqd
@@ -21,7 +21,7 @@ class CreateUsersTable extends Migration
             $table->string('password', 200)->nullable();
             $table->string('open_id', 200)->nullable();
             $table->string('nickname', 200)->nullable();
-            $table->string('avatar', 200)->nullable();
+            $table->string('avatar', 200)->nullable()->default('');
             $table->string('session_key', 200)->nullable();
             $table->string('token', 200)->nullable();
             $table->timestamps();

+ 32 - 0
database/migrations/2020_12_10_013450_create_work_points_table.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateWorkPointsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('work_points', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('name', 200)->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('work_points');
+    }
+}

+ 34 - 0
database/migrations/2020_12_10_013627_create_orders_table.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateOrdersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('orders', function (Blueprint $table) {
+            $table->increments('id');
+            $table->unsignedInteger('work_point_id')->nullable();
+            $table->string('remark', 200)->nullable();
+            $table->unsignedInteger('money')->nullable()->comment('单位:分');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('orders');
+    }
+}

+ 33 - 0
database/migrations/2020_12_10_013716_create_devices_table.php

xqd
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateDevicesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('devices', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('name', 200)->nullable();
+            $table->unsignedInteger('sort')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('devices');
+    }
+}

+ 35 - 0
database/migrations/2020_12_10_013730_create_order_devices_table.php

xqd
@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateOrderDevicesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('order_devices', function (Blueprint $table) {
+            $table->increments('id');
+            $table->unsignedInteger('order_id')->nullable();
+            $table->unsignedInteger('device_id')->nullable();
+            $table->unsignedInteger('quantity')->nullable();
+            $table->unsignedInteger('price')->nullable()->comment('单位:分');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('order_devices');
+    }
+}

+ 30 - 0
database/migrations/2020_12_10_020009_add_name_to_order_device.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddNameToOrderDevice extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('order_devices', function (Blueprint $table) {
+            $table->string('name', 200)->nullable()->after('id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 33 - 0
database/migrations/2020_12_10_031901_add_admin_user_id_to_orders.php

xqd
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddAdminUserIdToOrders extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->unsignedInteger('user_id')->nullable()->after('money');
+            $table->unsignedInteger('project_id')->nullable()->after('money');
+            $table->string('order_number', 100)->nullable()->after('money');
+            $table->unsignedInteger('status')->nullable()->after('money');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 30 - 0
database/migrations/2020_12_10_081251_add_is_draft_to_orders.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddIsDraftToOrders extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->tinyInteger('is_draft')->nullable()->after('money')->comment('1草稿2否')->default(2);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 36 - 0
database/migrations/2020_12_10_081639_create_options_table.php

xqd
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateOptionsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('options', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('table', 200)->nullable();
+            $table->string('column', 200)->nullable();
+            $table->string('key', 200)->nullable();
+            $table->string('name', 200)->nullable();
+            $table->unsignedInteger('sort')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('options');
+    }
+}

+ 30 - 0
database/migrations/2020_12_10_130450_add_color_to_options.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddColorToOptions extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('options', function (Blueprint $table) {
+            $table->string('color', 50)->nullable()->after('sort');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 30 - 0
database/migrations/2020_12_10_131931_add_level_to_project_role.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddLevelToProjectRole extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('project_roles', function (Blueprint $table) {
+            $table->integer('level')->nullable()->after('name');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 30 - 0
database/migrations/2020_12_10_132121_add_project_role_id_to_orders.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddProjectRoleIdToOrders extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->unsignedInteger('project_role_id')->nullable()->after('user_id')->comment('当前需要处理该项目的项目角色');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 31 - 0
database/migrations/2020_12_10_143957_add_last_project_role_id_to_orders.php

xqd
@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddLastProjectRoleIdToOrders extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('orders', function (Blueprint $table) {
+            $table->unsignedInteger('last_project_role_id')->nullable()->after('project_role_id')->comment('上一个处理该项目的项目角色');
+            $table->unsignedInteger('last_user_id')->nullable()->after('last_project_role_id')->comment('上一个处理该项目的成员');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 8 - 0
database/seeds/DatabaseSeeder.php

xqd
@@ -32,5 +32,13 @@ class DatabaseSeeder extends Seeder
             'created_at' => Carbon::now(),
             'updated_at' => Carbon::now()
         ]);
+
+        $this->call([
+            ProjectRoleSeeder::class,
+            ProjectSeeder::class,
+            WorkPointSeeder::class,
+            DeviceSeeder::class,
+            AdminMenuSeeder::class
+        ]);
     }
 }

+ 22 - 0
database/seeds/DeviceSeeder.php

xqd
@@ -0,0 +1,22 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class DeviceSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        $names = ['隧道掘进机', '钻机', '起重机械', '隧道牵引机械', '隧道掘进机', '混泥土泵送机械', '土石方机械', '运输机械', '其他'];
+        foreach($names as $key => $value) {
+            \App\Models\Device::create([
+                'name' => $value,
+                'sort' => $key + 1
+            ]);
+        }
+    }
+}

+ 121 - 0
database/seeds/MiniSeeder.php

xqd
@@ -0,0 +1,121 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class MiniSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        // 创建角色、用户
+        $total = 20;
+        \App\Models\Role::truncate();
+        \App\Models\User::truncate();
+        for($i = 1; $i < $total; ++$i) {
+            $role = \App\Models\Role::create([
+                'name' => '用户角色' . $i,
+                'sort' => $i,
+                'key' => 'role-' . $i
+            ]);
+
+            \App\Models\User::create([
+                'role_id' => $role->id,
+                'name' => '用户' . $i,
+                'password' => bcrypt(123456),
+                'phone' => $i < 10 ? '1234567890' . $i : '123456789' . $i
+            ]);
+        }
+
+        // 创建项目角色
+        \App\Models\ProjectRole::truncate();
+        for($i = 1; $i < $total; ++$i) {
+            \App\Models\ProjectRole::create([
+                'name' => '项目角色' . $i,
+                'level' => $i
+            ]);
+        }
+
+        // 创建项目,为项目分配用户和项目角色
+        \App\Models\Project::truncate();
+        \App\Models\ProjectUser::truncate();
+        $users = \App\Models\User::limit(3)->get();
+        $project_roles = \App\Models\ProjectRole::limit(3)->get();
+        for($i = 1; $i < $total; ++$i) {
+            $project = \App\Models\Project::create([
+                'name' => '项目' . ($i + 2)
+            ]);
+            for($j = 0; $j < count($users); ++$j) {
+                \App\Models\ProjectUser::create([
+                    'project_id' => $project->id,
+                    'user_id' => $users[$j]->id,
+                    'project_role_id' => $project_roles[$j]->id
+                ]);
+            }
+        }
+
+        // 创建设备类型
+        $device_types = ['隧道掘进机', '钻机', '起重机械', '隧道牵引机械', '隧道掘进机', '混泥土泵送机械', '土石方机械', '运输机械', '其他'];
+        foreach($device_types as $key => $value) {
+            \App\Models\Device::create([
+                'name' => $value,
+                'sort' => $key + 1
+            ]);
+        }
+
+        // 创建需求工点
+        \App\Models\WorkPoint::truncate();
+        for($i = 1; $i < $total; ++$i) {
+            \App\Models\WorkPoint::create([
+                'name' => '工点' . $i
+            ]);
+        }
+
+        // 创建订单状态
+        $this->call([
+            OptionSeeder::class
+        ]);
+
+        // 创建订单
+        \App\Models\Order::truncate();
+        \App\Models\OrderDevice::truncate();
+        $project = \App\Models\Project::first();
+        $statuses = \App\Models\Option::get('orders', 'status');
+        $work_points = \App\Models\WorkPoint::all();
+        $user = \App\Models\User::first();
+        $devices = \App\Models\Device::all();
+        for($i = 1; $i < 2 * $total; ++$i) {
+            $project_role = $project_roles->random();
+            $is_draft = collect([1, 2])->random();
+            $status = $statuses->random()->id;
+            $order = \App\Models\Order::create([
+                'work_point_id' => $work_points->random()->id,
+                'is_draft' => $is_draft,
+                'status' => $status,
+                'order_number' => \App\Models\Order::createOrderNumber(),
+                'project_id' => $project->id,
+                'user_id' => $user->id,
+                'project_role_id' => $project_role->id
+            ]);
+
+            $total = 0;
+
+            for($j = 1; $j < 3; ++$j) {
+                $quantity = mt_rand(1, 5);
+                $price = mt_rand(1, 10) * 1000;
+                $total = $total + $quantity * $price;
+                \App\Models\OrderDevice::create([
+                    'name' => '设备' . $j,
+                    'order_id' => $order->id,
+                    'device_id' => $devices->random()->id,
+                    'quantity' => $quantity,
+                    'price' => $price
+                ]);
+            }
+            $order->update(['money' => $total]);
+        }
+    }
+}

+ 36 - 0
database/seeds/OptionSeeder.php

xqd
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class OptionSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        \App\Models\Option::truncate();
+        $table = 'orders';
+        $column = 'status';
+        $items = [
+            ['name' => '待审核', 'key' => 'checking', 'color' => ''],
+            ['name' => '已完成', 'key' => 'pass'],
+            ['name' => '已驳回', 'key' => 'reject'],
+        ];
+        \App\Models\Option::where([
+            ['table', '=', $table],
+            ['column', '=', $column]
+        ])->delete();
+        foreach($items as $key => $val) {
+            \App\Models\Option::create([
+                'table' => $table,
+                'column' => $column,
+                'name' => $val['name'],
+                'key' => $val['key'],
+                'sort' => $key + 1
+            ]);
+        }
+    }
+}

+ 3 - 1
database/seeds/ProjectRoleSeeder.php

xqd
@@ -11,9 +11,11 @@ class ProjectRoleSeeder extends Seeder
      */
     public function run()
     {
+        \App\Models\ProjectRole::truncate();
         for($i = 0; $i < 10; ++$i) {
             \App\Models\ProjectRole::create([
-                'name' => '角色' . ($i + 2)
+                'name' => '角色' . ($i + 2),
+                'level' => ($i + 1)
             ]);
         }
     }

+ 20 - 0
database/seeds/WorkPointSeeder.php

xqd
@@ -0,0 +1,20 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class WorkPointSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        for($i = 0; $i < 10; ++$i) {
+            \App\Models\WorkPoint::create([
+                'name' => '工点' . ($i + 1)
+            ]);
+        }
+    }
+}

+ 23 - 21
mini/app.js

xqd
@@ -23,35 +23,37 @@ App({
       // }
     // })
     // 获取用户信息
-    wx.getSetting({
-      success: res => {
-        if (res.authSetting['scope.userInfo']) {
-          // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
-          wx.getUserInfo({
-            success: res => {
-              // 可以将 res 发送给后台解码出 unionId
-              this.globalData.userInfo = res.userInfo
+    // wx.getSetting({
+    //   success: res => {
+    //     if (res.authSetting['scope.userInfo']) {
+    //       // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
+    //       wx.getUserInfo({
+    //         success: res => {
+    //           // 可以将 res 发送给后台解码出 unionId
+    //           this.globalData.userInfo = res.userInfo
 
-              // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-              // 所以此处加入 callback 以防止这种情况
-              if (this.userInfoReadyCallback) {
-                this.userInfoReadyCallback(res)
-              }
-            }
-          })
-        }
-      }
-    })
+    //           // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+    //           // 所以此处加入 callback 以防止这种情况
+    //           if (this.userInfoReadyCallback) {
+    //             this.userInfoReadyCallback(res)
+    //           }
+    //         }
+    //       })
+    //     }
+    //   }
+    // })
   },
   globalData: {
     userInfo: null
   },
   loginCallback: function(data) {
-    var userInfo = data
-    this.globalData.userInfo = userInfo
-    wx.setStorageSync('sg-userinfo', userInfo)
+    this.updateUserInfo(data)
     wx.redirectTo({
       url: '/pages/index/index',
     })
+  },
+  updateUserInfo: function(info) {
+    this.globalData.userInfo = info
+    wx.setStorageSync('sg-userinfo', info)
   }
 })

+ 5 - 2
mini/app.json

xqd xqd
@@ -1,9 +1,11 @@
 {
   "pages": [
     "pages/index/index",
+    "pages/order/index",
+    "pages/project/index",
+    "pages/create-order/index",
     "pages/create-project-role/index",
     "pages/project-user/index",
-    "pages/project/index",
     "pages/create-project/index",
     "pages/login/index",
     "pages/logs/logs"
@@ -22,6 +24,7 @@
     "navbar": "/components/navbar",
     "van-icon": "@vant/weapp/icon/index",
     "van-search": "@vant/weapp/search/index",
-    "van-dialog": "@vant/weapp/dialog/index"
+    "van-dialog": "@vant/weapp/dialog/index",
+    "van-popup": "@vant/weapp/popup/index"
   }
 }

+ 41 - 0
mini/app.wxss

xqd xqd xqd xqd xqd xqd
@@ -14,6 +14,9 @@
 .sg-pad-top {
   padding-top: 30rpx;
 }
+.sg-pad-sm {
+  padding: 15rpx;
+}
 .sg-pad {
   padding: 30rpx;
 }
@@ -27,6 +30,12 @@
 .sg-primary-color {
   color: #195ED7;
 }
+.sg-white {
+  color: white;
+}
+.sg-white-bg {
+  background: white;
+}
 .sg-gray-color {
   color: rgba(16, 16, 16, 0.5);
 }
@@ -36,12 +45,21 @@
 .sg-bottom-border {
   border-bottom: 1px solid #ebedf0;
 }
+.sg-top-border {
+  border-top: 1px solid #ebedf0;
+}
+.sg-border-right {
+  border-right: 1px solid #ebedf0;
+}
 .sg-margin-top-sm {
   margin-top: 30rpx;
 }
 .sg-margin-top {
   margin-top: 50rpx;
 }
+.sg-margin-bottom {
+  margin-bottom: 30rpx;
+}
 .sg-margin-tb {
   margin: 30rpx 0;
 }
@@ -66,6 +84,10 @@
 .sg-index-color {
   color: #5693FC;
 }
+.sg-tabs .sg-tab.sg-selected {
+  color: #5693FC;
+  border-color: #5693FC;
+}
 .sg-avatar {
   width: 80rpx;
   border-radius: 50%;
@@ -87,6 +109,9 @@
 .sg-space-between {
   justify-content: space-between;
 }
+.sg-space-around {
+  justify-content: space-around;
+}
 .sg-flex-grow {
   flex-grow: 1;
 }
@@ -108,4 +133,20 @@
 .sg-red-bg {
   background: #ee0a24;
   color: white;
+}
+.sg-fix-bottom {
+  width: 100%;
+  position: fixed;
+  z-index: 100;
+  left: 0;
+  bottom: 0;
+}
+.sg-text-right {
+  text-align: right;
+}
+.sg-fix-top {
+  position: fixed;
+  left: 0;
+  top: 0;
+  width: 100%;
 }

+ 176 - 0
mini/pages/create-order/index.js

xqd
@@ -0,0 +1,176 @@
+// pages/create-order/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    tabs: ['设备租赁订单', '租赁设备添加'],
+    tabIndex: 0,
+    work_points: [],
+    pointIndex: -1,
+    id: -1,
+    project: null,
+    remark: '',
+    devices: [],
+    showAdd: false,
+    device_types: [],
+    typeIndex: -1,
+    device_name: '',
+    device_quantity: '',
+    device_price: ''
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    var id = options.id ? options.id : 1
+    this.setData({
+      id
+    })
+    api.getProject(this)
+    api.getByName(this, 'work-points/get', 'work_points');
+    api.getByName(this, 'devices/get', 'device_types');
+  },
+
+  submit: function(e) {
+    var type = e.currentTarget.dataset.type
+    var is_draft = type == 'draft' ? 1 : 2
+    if(this.data.pointIndex < 0) {
+      util.error('需求工点必填');
+      return false;
+    }
+    if(this.data.devices.length <= 0) {
+      util.error('请选择租赁设备');
+      return false;
+    }
+    var work_point = this.data.work_points[this.data.pointIndex]
+    http({
+      url: 'orders/create',
+      data: {
+        project_id: this.data.id,
+        work_point_id: work_point.id,
+        remark: this.data.remark,
+        devices: this.data.devices,
+        is_draft: is_draft
+      },
+      success: function(res) {
+        if(res.code == 0) {
+          util.success('操作成功')
+        }
+      }
+    })
+  },
+
+  switchTab: function(e) {
+    this.setData({
+      tabIndex: e.currentTarget.dataset.index
+    })
+  },
+
+  deleteDevice: function(e) {
+    var devices = this.data.devices
+    var index = e.currentTarget.dataset.index
+    devices.splice(index, 1)
+    this.setData({
+      devices
+    })
+  },
+
+  addDevice: function() {
+    if(!this.data.device_name) {
+      util.error('设备名称必填');
+      return false;
+    }
+    if(!this.data.typeIndex < 0) {
+      util.error('设备类型必填')
+      return false
+    }
+    if(!this.data.device_quantity) {
+      util.error('设备数量必填')
+      return false
+    }
+    if(!this.data.device_price) {
+      util.error('设备单价必填')
+      return false
+    }
+    var devices = this.data.devices
+    var type = this.data.device_types[this.data.typeIndex]
+    devices.push({
+      name: this.data.device_name,
+      type_name: type.name,
+      type_id: type.id,
+      quantity: this.data.device_quantity,
+      price: this.data.device_price
+    })
+    this.setData({
+      devices
+    })
+  },
+
+  onChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: e.detail.value
+    })
+  },
+
+  switchShowAdd: function(e) {
+    this.setData({
+      showAdd: e.currentTarget.dataset.show
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
mini/pages/create-order/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "创建订单",
+  "usingComponents": {}
+}

+ 83 - 0
mini/pages/create-order/index.wxml

xqd
@@ -0,0 +1,83 @@
+<!--pages/create-order/index.wxml-->
+<view class="sg-container">
+  <view class="sg-tabs sg-flex sg-align-center sg-space-around">
+    <block wx:for="{{tabs}}" wx:key="index">
+      <view class="sg-tab sg-pad {{index == tabIndex ? 'sg-seleted' : 'sg-gray-color'}}" bindtap="switchTab" data-index="{{index}}">{{item}}</view>
+    </block>
+  </view>
+  <view class="sg-order-box" wx:if="{{tabIndex == 0}}">
+    <view class="sg-form">
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">项目名称</view>
+        <input value="{{project ? project.name : ''}}" class="sg-input" disabled="true"></input>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">需求工点</view>
+        <picker bindchange="onChange" value="{{pointIndex}}" range="{{work_points}}" range-key="name"
+          data-name="pointIndex" class="sg-input">
+          <view class="picker sg-gray-color">
+            {{pointIndex >= 0 ? work_points[pointIndex].name : '选择所需的工点'}}
+          </view>
+        </picker>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">备注</view>
+        <input value="{{remark}}" class="sg-input" bindinput="onChange" data-name="remark" placeholder="订单备注填写"></input>
+      </view>
+    </view>
+  </view>
+  <view class="sg-device-box" wx:if="{{tabIndex == 1}}">
+    <view class="sg-device-list sg-top-border">
+      <block wx:if="{{devices.length <= 0}}">
+        <view class="sg-center sg-pad">暂无设备</view>
+      </block>
+      <block wx:else>
+        <view class="sg-item sg-flex sg-align-center sg-bottom-border" wx:for="{{devices}}" wx:key="index" bindtap="selectDevice" data-index="{{index}}">
+          <view class="sg-left sg-flex sg-justify-center sg-space-between sg-flex-grow sg-pad">
+            <view class="sg-name">{{item.type_name}}-{{item.name}}</view>
+            <view class="sg-quantity-price sg-gray-color">
+              ¥<text>{{item.price}}</text> × <text>{{item.quantity}}</text>
+            </view>
+          </view>
+          <view class="sg-right sg-red-bg sg-pad" bindtap="deleteDevice" data-index="{{index}}">删除</view>
+        </view>
+      </block>
+    </view>
+  </view>
+  <van-dialog show="{{ showAdd }}" use-slot title="添加设备" show-cancel-button bind:confirm="addDevice">
+    <view class="sg-add-device-box sg-pad">
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">设备名称</view>
+        <input value="{{device_name}}" class="sg-input" bindinput="onChange" data-name="device_name"
+          placeholder="请输入设备名称"></input>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">设备类型</view>
+        <picker bindchange="onChange" value="{{typeIndex}}" range="{{device_types}}" range-key="name"
+          data-name="typeIndex" class="sg-input">
+          <view class="picker sg-gray-color">
+            {{typeIndex >= 0 ? device_types[typeIndex].name : '选择设备类型'}}
+          </view>
+        </picker>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">设备数量</view>
+        <input value="{{device_quantity}}" class="sg-input" bindinput="onChange" data-name="device_quantity"
+          placeholder="请输入设备数量"></input>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">设备单价</view>
+        <input value="{{device_price}}" class="sg-input" bindinput="onChange" data-name="device_price"
+          placeholder="请输入设备单价"></input>
+      </view>
+    </view>
+  </van-dialog>
+  <view class="sg-submit-box sg-pad sg-fix-bottom sg-flex sg-align-center sg-center" wx:if="{{tabIndex == 1}}"
+    bindtap="switchShowAdd" data-show="true">
+    <van-icon name="plus" /><text>立即添加</text>
+  </view>
+  <view class="sg-submit-box sg-fix-bottom sg-flex sg-align-center sg-center" wx:if="{{tabIndex == 0}}">
+    <view class="sg-action sg-draft sg-pad sg-border-right" bindtap="submit" data-type='draft'>暂存</view>
+    <view class="sg-action sg-pad sg-index-bg sg-white" bindtap="submit" data-type='save'>提交</view>
+  </view>
+</view>

+ 43 - 0
mini/pages/create-order/index.wxss

xqd
@@ -0,0 +1,43 @@
+/* pages/create-order/index.wxss */
+.sg-tabs {
+  background: white;
+}
+.sg-tab {
+  width: 50%;
+  box-sizing: border-box;
+  text-align: center;
+}
+.sg-tab:first-child {
+  border-right: 1px solid #ebedf0;
+}
+.sg-form-item {
+  display: flex;
+  width: 100%;
+  box-sizing: border-box;
+}
+.sg-form-item .sg-label {
+  padding-right: 30rpx;
+  min-width: 150rpx;
+}
+.sg-form-item .sg-input {
+  flex-grow: 1;
+  text-align: right;
+}
+.sg-order-box {
+  background: white;
+}
+.sg-submit-box {
+  justify-content: center;
+  background: white;
+}
+.sg-device-list .sg-item {
+  background: white;
+  align-items: center;
+}
+.sg-device-list .sg-item .sg-left {
+  display: flex;
+  align-items: center;
+}
+.sg-submit-box .sg-action {
+  width: 50%;
+}

+ 3 - 0
mini/pages/login/index.wxss

xqd
@@ -21,4 +21,7 @@
   display: flex;
   align-items: center;
   justify-content: center;
+}
+.sg-container {
+  background: transparent;
 }

+ 129 - 0
mini/pages/order/index.js

xqd
@@ -0,0 +1,129 @@
+// pages/order/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    id: -1,
+    project: null,
+    tabs: ['全部订单', '待审核', '已审核', '已完成', '已驳回'],
+    statuses: ['', 'checking', 'checked', 'pass', 'reject'],
+    list: [[], [], [], [], []],
+    pages: [1, 1, 1, 1, 1],
+    tabIndex: 0,
+    touchBottom: [false, false, false, false, false],
+    work_points: [],
+    pointIndex: -1
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    var id = options.id ? options.id : 1
+    this.setData({
+      id
+    })
+    api.getProject(this)
+    api.getByName(this, 'work-points/get', 'work_points');
+    this.getList();
+  },
+
+  getList: function() {
+    var index = this.data.tabIndex
+    var touchBottom = this.data.touchBottom[index]
+    if(touchBottom) return false;
+    var status = this.data.statuses[index]
+    var page = this.data.pages[index]
+    var that = this
+    http({
+      url: 'orders/get',
+      data: {
+        project_id: this.data.id,
+        status: status,
+        page: page
+      },
+      success: function(res) {
+        if(res.code == 0) {
+         var list = that.data.list
+         var touchBottom = that.data.touchBottom
+         list[index] = list[index].concat(res.data);
+         if(res.data.length <= 0) {
+           touchBottom[index] = true;
+         }
+         that.setData({
+           touchBottom,
+           list
+         })
+        }
+      }
+    })
+  },
+
+  switchTab: function(e) {
+    var index = e.currentTarget.dataset.index
+    this.setData({
+      tabIndex: index
+    })
+  },
+
+  onChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: e.detail.value
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 3 - 0
mini/pages/order/index.json

xqd
@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 50 - 0
mini/pages/order/index.wxml

xqd
@@ -0,0 +1,50 @@
+<!--pages/order/index.wxml-->
+<view class="sg-container">
+  <view class="sg-top-box sg-fix-top">
+    <view class="sg-search-box sg-pad sg-flex sg-align-center sg-margin">
+      <view class="sg-left sg-flex-grow sg-border">
+        <picker bindchange="onChange" value="{{pointIndex}}" range="{{work_points}}" range-key="name"
+          data-name="pointIndex" class="sg-input">
+          <view class="picker sg-gray-color">
+            {{pointIndex >= 0 ? work_points[pointIndex].name : '选择所需的工点'}}
+          </view>
+        </picker>
+      </view>
+      <van-icon name="search" class="sg-icon sg-index-color" />
+    </view>
+    <view class="sg-tabs sg-flex sg-align-center sg-white-bg sg-pad sg-bottom-border sg-top-border sg-font-small">
+      <view wx:for="{{tabs}}" wx:key="index" class="sg-tab {{tabIndex == index ? 'sg-selected' : ''}}"
+        bindtap="switchTab" data-index="{{index}}">{{ item }}</view>
+    </view>
+  </view>
+  <view class="sg-list-box sg-pad">
+    <view class="sg-list" wx:for="{{list}}" wx:if="{{tabIndex == index}}" wx:key="index">
+      <view class="sg-item sg-white-bg sg-pad sg-margin-bottom sg-font-small" wx:for="{{item}}" wx:for-item="i_item"
+        wx:for-index="i_index" wx:key="i_index">
+        <view class="sg-top sg-bottom-border">
+          <view class="sg-order-status sg-flex sg-align-center sg-space-between sg-margin-bottom">
+            <view class="sg-order sg-gray-color">订单号:{{i_item.order_number}}</view>
+            <view class="sg-status">{{i_item.status}}</view>
+          </view>
+          <view class="sg-device-info">
+            <view class="sg-label">租借设备概要:</view>
+            <view class="sg-device-item sg-flex sg-align-center sg-space-between sg-margin-tb-sm"
+              wx:for="{{i_item.devices}}" wx:for-item="j_item" wx:for-index="j_index" wx:key="j_index">
+              <view class="sg-name">{{j_index+1}}.{{j_item.type}}-{{j_item.name}}</view>
+              <view class="sg-price">¥{{j_item.price}}×{{j_item.quantity}}</view>
+            </view>
+          </view>
+          <view class="sg-total sg-text-right sg-margin-tb-sm">合计:¥{{i_item.money}}</view>
+        </view>
+        <view class="sg-bottom sg-flex sg-align-center sg-space-between">
+          <view class="sg-left">
+            <view class="sg-left-item sg-margin-tb-sm">需求工点:{{i_item.work_point_name}}</view>
+            <view class="sg-left-item sg-margin-tb-sm">提交人:{{i_item.user_name}}</view>
+            <view class="sg-left-item sg-margin-tb-sm">创建时间:{{i_item.date_time}}</view>
+          </view>
+          <view class="sg-right sg-index-bg sg-pad-sm sg-white">查看详情</view>
+        </view>
+      </view>
+    </view>
+  </view>
+</view>

+ 21 - 0
mini/pages/order/index.wxss

xqd
@@ -0,0 +1,21 @@
+/* pages/order/index.wxss */
+.sg-search-box {
+  background: white;
+}
+.sg-search-box .sg-left {
+  margin-right: 30rpx;
+}
+.sg-tabs {
+  justify-content: space-around;
+}
+.sg-tabs .sg-tab {
+  padding-bottom: 15rpx;
+  box-sizing: border-box;
+  border-bottom: 2px solid white;
+}
+.sg-container .sg-tabs {
+  padding-bottom: 15rpx;
+}
+.sg-list-box {
+  margin-top: 200rpx;
+}

+ 8 - 2
mini/pages/project/index.js

xqd xqd xqd xqd
@@ -1,6 +1,7 @@
 // pages/project/index.js
 import http from '../../utils/http'
 import util from '../../utils/util'
+import api from '../../utils/api'
 var app = getApp()
 Page({
 
@@ -13,7 +14,8 @@ Page({
     device_rent_menus: [{
       img: 'http://t18.9026.com/mini/create-order.png',
       title: '创建订单',
-      desc: '创建外部设备租赁订单'
+      desc: '创建外部设备租赁订单',
+      url: '/pages/create-order/index'
     }, {
       img: 'http://t18.9026.com/mini/rent-check.png',
       title: '租赁审核',
@@ -25,7 +27,8 @@ Page({
     }, {
       img: 'http://t18.9026.com/mini/all-order.png',
       title: '所有订单',
-      desc: '查看全部设备租赁订单'
+      desc: '查看全部设备租赁订单',
+      url: '/pages/order/index'
     }],
     device_use_menus: [{
       img: 'http://t18.9026.com/mini/use-apply.png',
@@ -64,6 +67,9 @@ Page({
       id: id,
       userInfo: app.globalData.userInfo
     })
+    api.getByName(this, 'getUserInfo', 'userInfo', function(res) {
+      app.updateUserInfo(res.data);
+    });
   },
 
   navigate: function(e) {

+ 11 - 7
mini/pages/project/index.wxml

xqd xqd xqd
@@ -1,7 +1,7 @@
 <!--pages/project/index.wxml-->
 <view class="sg-container">
   <view class="sg-user-box sg-pad sg-flex sg-align-center">
-    <image class="sg-big-avatar" src="{{userInfo.avatarUrl}}" mode="widthFix"></image>
+    <image class="sg-big-avatar" src="{{userInfo.avatar ? userInfo.avatar : userInfo.avatarUrl}}" mode="widthFix"></image>
     <view class="sg-right sg-flex-grow">
       <view class="sg-name">{{userInfo.name}}</view>
       <view
@@ -11,7 +11,9 @@
       </view>
       <view class="sg-phone-user sg-flex sg-align-center sg-space-between">
         <view class="sg-phone sg-gray-color sg-font-small">{{ userInfo.phone }}</view>
-        <view class="sg-user sg-font-small sg-index-color sg-flex sg-align-center" bindtap="navigate" data-url="/pages/project-user/index?id={{id}}"><van-icon name="user-o" /><text>人员管理</text></view>
+        <view class="sg-user sg-font-small sg-index-color sg-flex sg-align-center" bindtap="navigate"
+          data-url="/pages/project-user/index?id={{id}}">
+          <van-icon name="user-o" /><text>人员管理</text></view>
       </view>
     </view>
   </view>
@@ -21,11 +23,13 @@
       <text class="sg-sub-title sg-gray-color">外部设备租赁</text>
     </view>
     <view class="sg-menu-list">
-      <view class="sg-item sg-flex sg-align-center sg-pad" wx:for="{{device_rent_menus}}" wx:key="index">
-        <image class="sg-img" src="{{item.img}}" mode="widthFix"></image>
-        <view class="sg-name sg-margin-top-sm">{{item.title}}</view>
-        <view class="sg-desp sg-margin-top-sm sg-gray-color sg-font-xs">{{item.desc}}</view>
-      </view>
+      <block wx:for="{{device_rent_menus}}" wx:key="index">
+        <view class="sg-item sg-flex sg-align-center sg-pad" bindtap="navigate" data-url="{{item.url}}?id={{id}}">
+          <image class="sg-img" src="{{item.img}}" mode="widthFix"></image>
+          <view class="sg-name sg-margin-top-sm">{{item.title}}</view>
+          <view class="sg-desp sg-margin-top-sm sg-gray-color sg-font-xs">{{item.desc}}</view>
+        </view>
+      </block>
     </view>
   </view>
   <view class="sg-menu-box sg-pad">

+ 42 - 0
mini/utils/api.js

xqd
@@ -0,0 +1,42 @@
+import http from '../utils/http'
+
+const getProject = (that, success = null, error = null) => {
+  http({
+    url: 'projects/detail',
+    data: {
+      id: that.data.id
+    },
+    success: function(res) {
+      if(res.code == 0) {
+        that.setData({
+          project: res.data
+        })
+      }
+      typeof success === "function" && success(res.data)
+    },
+    error: error
+  })
+}
+
+const getByName = (that, url, name, data={}, success=null, error={}) => {
+  http({
+    url: url,
+    data: data,
+    success: function(res) {
+      if(res.code == 0) {
+        that.setData({
+          [name]: res.data
+        })
+      }
+      typeof success === "function" && success(res.data)
+    },
+    error: error
+  })
+}
+
+const api = {
+  getProject,
+  getByName
+}
+
+export default api

+ 1 - 1
mini/utils/util.js

xqd
@@ -15,7 +15,7 @@ const formatNumber = n => {
 }
 
 const checkMobile = mobile => {
-  return /^1[34578]\d{9}$/.test(mobile)
+  return /^1[234578]\d{9}$/.test(mobile)
 }
 
 const error = msg => {

BIN
public/mini/default-user.png


+ 8 - 0
routes/api.php

xqd xqd
@@ -19,6 +19,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\mini', 'prefix' =>
     $api->any('login', 'AuthController@login');
     $api->any('reset', 'AuthController@reset');
     $api->any('loginByWechat', 'AuthController@loginByWechat');
+    $api->any('getUserInfo', 'AuthController@getUserInfo');
 
     $api->any('projects/create', 'ProjectController@create');
     $api->any('projects/get', 'ProjectController@get');
@@ -36,4 +37,11 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\mini', 'prefix' =>
     $api->any('project-users/detail', 'ProjectUserController@detail');
 
     $api->any('users/search', 'UserController@search');
+
+    $api->any('work-points/get', 'WorkPointController@get');
+
+    $api->any('devices/get', 'DeviceController@get');
+
+    $api->any('orders/create', 'OrderController@create');
+    $api->any('orders/get', 'OrderController@get');
 });